opticore-catch-exception-error 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +118 -107
- package/dist/index.d.cts +34 -19
- package/dist/index.d.ts +34 -19
- package/dist/index.js +119 -108
- package/example/index.ts +2 -2
- package/package.json +2 -2
- package/dist/utils/translations/message.translation.en.json +0 -58
- package/dist/utils/translations/message.translation.fr.json +0 -58
package/dist/index.js
CHANGED
|
@@ -148,47 +148,45 @@ import colors from "ansi-colors";
|
|
|
148
148
|
import chalk from "chalk";
|
|
149
149
|
import { LoggerCore } from "opticore-logger";
|
|
150
150
|
import { HttpStatusCode as status11 } from "opticore-http-response";
|
|
151
|
-
import {
|
|
151
|
+
import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
152
152
|
|
|
153
153
|
// src/utils/dateTimeFormatted.utils.ts
|
|
154
154
|
var dateTimeFormatted = `${(/* @__PURE__ */ new Date()).getMonth()}-${(/* @__PURE__ */ new Date()).getDate()}-${(/* @__PURE__ */ new Date()).getFullYear()} ${(/* @__PURE__ */ new Date()).getHours()}:${(/* @__PURE__ */ new Date()).getMinutes()}:${(/* @__PURE__ */ new Date()).getSeconds()}`;
|
|
155
155
|
|
|
156
|
-
// src/core/errors/events/serverListen.event.error.ts
|
|
157
|
-
import { getEnvVariable as getEnvVariable2 } from "opticore-env-access";
|
|
158
|
-
|
|
159
156
|
// src/core/config/loaders/translateLanguage.loader.ts
|
|
160
157
|
import path from "path";
|
|
161
158
|
import { createRequire } from "module";
|
|
162
159
|
import { TranslationLoader } from "opticore-translator";
|
|
163
|
-
|
|
164
|
-
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
160
|
+
var translateCatchExceptionErrorLanguageLoader = (defaultLocalLang) => {
|
|
165
161
|
const require2 = createRequire(import.meta.url);
|
|
166
162
|
const packagePath = path.dirname(require2.resolve("opticore-catch-exception-error"));
|
|
167
163
|
const translateMsgJsonFilePath = path.join(packagePath, "utils", "translations");
|
|
168
|
-
TranslationLoader.loadTranslations(translateMsgJsonFilePath,
|
|
164
|
+
TranslationLoader.loadTranslations(translateMsgJsonFilePath, defaultLocalLang);
|
|
169
165
|
};
|
|
170
166
|
|
|
171
167
|
// src/core/errors/events/serverListen.event.error.ts
|
|
172
168
|
var ServerListenEventError = class {
|
|
173
169
|
static logger = new LoggerCore();
|
|
174
170
|
static stackTrace;
|
|
175
|
-
static __init() {
|
|
176
|
-
translateCatchExceptionErrorLanguageLoader();
|
|
171
|
+
static __init(defaultLocalLang) {
|
|
172
|
+
translateCatchExceptionErrorLanguageLoader(defaultLocalLang);
|
|
177
173
|
return this;
|
|
178
174
|
}
|
|
179
175
|
/**
|
|
180
176
|
*
|
|
177
|
+
* @param defaultLocalLang
|
|
178
|
+
* @param appPort
|
|
181
179
|
*/
|
|
182
|
-
static hostPortUndefined() {
|
|
180
|
+
static hostPortUndefined(defaultLocalLang, appPort) {
|
|
183
181
|
this.stackTrace = this.traceError(
|
|
184
|
-
TranslationLoader2.t("errorHostUrl",
|
|
185
|
-
TranslationLoader2.t("listening",
|
|
182
|
+
TranslationLoader2.t("errorHostUrl", defaultLocalLang),
|
|
183
|
+
TranslationLoader2.t("listening", defaultLocalLang),
|
|
186
184
|
status11.BAD_REQUEST
|
|
187
185
|
);
|
|
188
186
|
this.logger.error(
|
|
189
187
|
this.stackTrace.message,
|
|
190
|
-
TranslationLoader2.t("webServer",
|
|
191
|
-
TranslationLoader2.t("badPort",
|
|
188
|
+
TranslationLoader2.t("webServer", defaultLocalLang),
|
|
189
|
+
TranslationLoader2.t("badPort", defaultLocalLang, { badPort: appPort }),
|
|
192
190
|
this.stackTrace.stack,
|
|
193
191
|
status11.BAD_REQUEST
|
|
194
192
|
);
|
|
@@ -196,17 +194,19 @@ var ServerListenEventError = class {
|
|
|
196
194
|
}
|
|
197
195
|
/**
|
|
198
196
|
*
|
|
197
|
+
* @param defaultLocalLang
|
|
198
|
+
* @param appHost
|
|
199
199
|
*/
|
|
200
|
-
static hostUndefined() {
|
|
200
|
+
static hostUndefined(defaultLocalLang, appHost) {
|
|
201
201
|
this.stackTrace = this.traceError(
|
|
202
|
-
TranslationLoader2.t("badHost",
|
|
203
|
-
TranslationLoader2.t("listening",
|
|
202
|
+
TranslationLoader2.t("badHost", defaultLocalLang, { badHost: appHost }),
|
|
203
|
+
TranslationLoader2.t("listening", defaultLocalLang),
|
|
204
204
|
status11.BAD_REQUEST
|
|
205
205
|
);
|
|
206
206
|
this.logger.error(
|
|
207
207
|
this.stackTrace.message,
|
|
208
|
-
TranslationLoader2.t("webServer",
|
|
209
|
-
TranslationLoader2.t("badHost",
|
|
208
|
+
TranslationLoader2.t("webServer", defaultLocalLang),
|
|
209
|
+
TranslationLoader2.t("badHost", defaultLocalLang),
|
|
210
210
|
this.stackTrace.stack,
|
|
211
211
|
status11.BAD_REQUEST
|
|
212
212
|
);
|
|
@@ -215,16 +215,16 @@ var ServerListenEventError = class {
|
|
|
215
215
|
/**
|
|
216
216
|
*
|
|
217
217
|
*/
|
|
218
|
-
static portUndefined() {
|
|
218
|
+
static portUndefined(defaultLocalLang) {
|
|
219
219
|
this.stackTrace = this.traceError(
|
|
220
|
-
TranslationLoader2.t("badPort",
|
|
221
|
-
TranslationLoader2.t("listening",
|
|
220
|
+
TranslationLoader2.t("badPort", defaultLocalLang),
|
|
221
|
+
TranslationLoader2.t("listening", defaultLocalLang),
|
|
222
222
|
status11.BAD_REQUEST
|
|
223
223
|
);
|
|
224
224
|
this.logger.error(
|
|
225
225
|
this.stackTrace.message,
|
|
226
|
-
TranslationLoader2.t("webServer",
|
|
227
|
-
TranslationLoader2.t("badHost",
|
|
226
|
+
TranslationLoader2.t("webServer", defaultLocalLang),
|
|
227
|
+
TranslationLoader2.t("badHost", defaultLocalLang),
|
|
228
228
|
this.stackTrace.stack,
|
|
229
229
|
status11.BAD_REQUEST
|
|
230
230
|
);
|
|
@@ -233,12 +233,13 @@ var ServerListenEventError = class {
|
|
|
233
233
|
/**
|
|
234
234
|
*
|
|
235
235
|
* @param err
|
|
236
|
+
* @param defaultLocalLang
|
|
236
237
|
*/
|
|
237
|
-
static onEventError(err) {
|
|
238
|
+
static onEventError(err, defaultLocalLang) {
|
|
238
239
|
this.logger.error(
|
|
239
|
-
TranslationLoader2.t(err.message,
|
|
240
|
-
TranslationLoader2.t("serverStart",
|
|
241
|
-
TranslationLoader2.t("serverStartError",
|
|
240
|
+
TranslationLoader2.t(err.message, defaultLocalLang),
|
|
241
|
+
TranslationLoader2.t("serverStart", defaultLocalLang),
|
|
242
|
+
TranslationLoader2.t("serverStartError", defaultLocalLang, { err }),
|
|
242
243
|
err.stack,
|
|
243
244
|
status11.SERVICE_UNAVAILABLE
|
|
244
245
|
);
|
|
@@ -264,17 +265,18 @@ var ServerListenEventError = class {
|
|
|
264
265
|
/**
|
|
265
266
|
*
|
|
266
267
|
* @param code
|
|
268
|
+
* @param defaultLocalLang
|
|
267
269
|
*/
|
|
268
|
-
static processBeforeExit(code) {
|
|
270
|
+
static processBeforeExit(code, defaultLocalLang) {
|
|
269
271
|
this.stackTrace = this.traceError(
|
|
270
|
-
TranslationLoader2.t("processExitCode",
|
|
271
|
-
TranslationLoader2.t("beforeExit",
|
|
272
|
+
TranslationLoader2.t("processExitCode", defaultLocalLang, { processExitCode: code }),
|
|
273
|
+
TranslationLoader2.t("beforeExit", defaultLocalLang),
|
|
272
274
|
status11.SERVICE_UNAVAILABLE
|
|
273
275
|
);
|
|
274
276
|
this.logger.error(
|
|
275
277
|
this.stackTrace.message,
|
|
276
|
-
TranslationLoader2.t("beforeExit",
|
|
277
|
-
TranslationLoader2.t("processBeforeExit",
|
|
278
|
+
TranslationLoader2.t("beforeExit", defaultLocalLang),
|
|
279
|
+
TranslationLoader2.t("processBeforeExit", defaultLocalLang),
|
|
278
280
|
this.stackTrace.stack,
|
|
279
281
|
status11.SERVICE_UNAVAILABLE
|
|
280
282
|
);
|
|
@@ -283,16 +285,16 @@ var ServerListenEventError = class {
|
|
|
283
285
|
/**
|
|
284
286
|
*
|
|
285
287
|
*/
|
|
286
|
-
static processDisconnected() {
|
|
288
|
+
static processDisconnected(defaultLocalLang) {
|
|
287
289
|
this.stackTrace = this.traceError(
|
|
288
|
-
TranslationLoader2.t("childProcessDiscon",
|
|
289
|
-
TranslationLoader2.t("processDiscon",
|
|
290
|
+
TranslationLoader2.t("childProcessDiscon", defaultLocalLang),
|
|
291
|
+
TranslationLoader2.t("processDiscon", defaultLocalLang),
|
|
290
292
|
status11.SERVICE_UNAVAILABLE
|
|
291
293
|
);
|
|
292
294
|
this.logger.error(
|
|
293
295
|
this.stackTrace.message,
|
|
294
|
-
TranslationLoader2.t("disconnected"),
|
|
295
|
-
TranslationLoader2.t("processDiscon"),
|
|
296
|
+
TranslationLoader2.t("disconnected", defaultLocalLang),
|
|
297
|
+
TranslationLoader2.t("processDiscon", defaultLocalLang),
|
|
296
298
|
this.stackTrace.stack,
|
|
297
299
|
status11.SERVICE_UNAVAILABLE
|
|
298
300
|
);
|
|
@@ -301,30 +303,31 @@ var ServerListenEventError = class {
|
|
|
301
303
|
/**
|
|
302
304
|
*
|
|
303
305
|
* @param code
|
|
306
|
+
* @param defaultLocalLang
|
|
304
307
|
*/
|
|
305
|
-
static exited(code) {
|
|
308
|
+
static exited(code, defaultLocalLang) {
|
|
306
309
|
switch (code) {
|
|
307
310
|
case 0:
|
|
308
311
|
this.logger.success(
|
|
309
|
-
TranslationLoader2.t("completed",
|
|
310
|
-
TranslationLoader2.t("finishingProcessWell",
|
|
312
|
+
TranslationLoader2.t("completed", defaultLocalLang, { code }),
|
|
313
|
+
TranslationLoader2.t("finishingProcessWell", defaultLocalLang, { code })
|
|
311
314
|
);
|
|
312
315
|
console.log("");
|
|
313
316
|
const paddingLength = 35;
|
|
314
317
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
315
318
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
316
|
-
console.log(`${colors.bgGreen(` ${TranslationLoader2.t("serverStopped",
|
|
319
|
+
console.log(`${colors.bgGreen(` ${TranslationLoader2.t("serverStopped", defaultLocalLang)} `)}`);
|
|
317
320
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
318
321
|
break;
|
|
319
322
|
case 1:
|
|
320
323
|
this.stackTrace = this.traceError(
|
|
321
|
-
TranslationLoader2.t("somethingWentWrong",
|
|
322
|
-
TranslationLoader2.t("genErrors",
|
|
324
|
+
TranslationLoader2.t("somethingWentWrong", defaultLocalLang),
|
|
325
|
+
TranslationLoader2.t("genErrors", defaultLocalLang),
|
|
323
326
|
status11.SERVICE_UNAVAILABLE
|
|
324
327
|
);
|
|
325
328
|
this.logger.error(
|
|
326
329
|
this.stackTrace.message,
|
|
327
|
-
TranslationLoader2.t("exited",
|
|
330
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
328
331
|
"General Errors",
|
|
329
332
|
this.stackTrace.stack,
|
|
330
333
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -332,27 +335,27 @@ var ServerListenEventError = class {
|
|
|
332
335
|
break;
|
|
333
336
|
case 2:
|
|
334
337
|
this.stackTrace = this.traceError(
|
|
335
|
-
TranslationLoader2.t("incorrectCmd",
|
|
336
|
-
TranslationLoader2.t("misuseShell",
|
|
338
|
+
TranslationLoader2.t("incorrectCmd", defaultLocalLang),
|
|
339
|
+
TranslationLoader2.t("misuseShell", defaultLocalLang),
|
|
337
340
|
status11.SERVICE_UNAVAILABLE
|
|
338
341
|
);
|
|
339
342
|
this.logger.error(
|
|
340
343
|
this.stackTrace.message,
|
|
341
|
-
TranslationLoader2.t("exited",
|
|
342
|
-
TranslationLoader2.t("incorrectCmd",
|
|
344
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
345
|
+
TranslationLoader2.t("incorrectCmd", defaultLocalLang),
|
|
343
346
|
this.stackTrace.stack,
|
|
344
347
|
status11.SERVICE_UNAVAILABLE
|
|
345
348
|
);
|
|
346
349
|
break;
|
|
347
350
|
case 126:
|
|
348
351
|
this.stackTrace = this.traceError(
|
|
349
|
-
TranslationLoader2.t("incorrectCmd",
|
|
350
|
-
TranslationLoader2.t("cmdNotExecutable",
|
|
352
|
+
TranslationLoader2.t("incorrectCmd", defaultLocalLang),
|
|
353
|
+
TranslationLoader2.t("cmdNotExecutable", defaultLocalLang),
|
|
351
354
|
status11.SERVICE_UNAVAILABLE
|
|
352
355
|
);
|
|
353
356
|
this.logger.error(
|
|
354
357
|
this.stackTrace.message,
|
|
355
|
-
TranslationLoader2.t("exited",
|
|
358
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
356
359
|
this.stackTrace.name,
|
|
357
360
|
this.stackTrace.stack,
|
|
358
361
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -360,13 +363,13 @@ var ServerListenEventError = class {
|
|
|
360
363
|
break;
|
|
361
364
|
case 127:
|
|
362
365
|
this.stackTrace = this.traceError(
|
|
363
|
-
TranslationLoader2.t("cmdNotFound",
|
|
364
|
-
TranslationLoader2.t("cmdNotFoundInSystemPath",
|
|
366
|
+
TranslationLoader2.t("cmdNotFound", defaultLocalLang),
|
|
367
|
+
TranslationLoader2.t("cmdNotFoundInSystemPath", defaultLocalLang),
|
|
365
368
|
status11.SERVICE_UNAVAILABLE
|
|
366
369
|
);
|
|
367
370
|
this.logger.error(
|
|
368
371
|
this.stackTrace.message,
|
|
369
|
-
TranslationLoader2.t("exited",
|
|
372
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
370
373
|
this.stackTrace.name,
|
|
371
374
|
this.stackTrace.stack,
|
|
372
375
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -374,13 +377,13 @@ var ServerListenEventError = class {
|
|
|
374
377
|
break;
|
|
375
378
|
case 128:
|
|
376
379
|
this.stackTrace = this.traceError(
|
|
377
|
-
TranslationLoader2.t("cmdNotFoundInSystemPath",
|
|
378
|
-
TranslationLoader2.t("argInvalid",
|
|
380
|
+
TranslationLoader2.t("cmdNotFoundInSystemPath", defaultLocalLang),
|
|
381
|
+
TranslationLoader2.t("argInvalid", defaultLocalLang),
|
|
379
382
|
status11.SERVICE_UNAVAILABLE
|
|
380
383
|
);
|
|
381
384
|
this.logger.error(
|
|
382
385
|
this.stackTrace.message,
|
|
383
|
-
TranslationLoader2.t("exited",
|
|
386
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
384
387
|
this.stackTrace.name,
|
|
385
388
|
this.stackTrace.stack,
|
|
386
389
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -388,13 +391,13 @@ var ServerListenEventError = class {
|
|
|
388
391
|
break;
|
|
389
392
|
case 130:
|
|
390
393
|
this.stackTrace = this.traceError(
|
|
391
|
-
TranslationLoader2.t("scriptEndedManuallyByCtrlC",
|
|
392
|
-
TranslationLoader2.t("scriptEnded",
|
|
394
|
+
TranslationLoader2.t("scriptEndedManuallyByCtrlC", defaultLocalLang),
|
|
395
|
+
TranslationLoader2.t("scriptEnded", defaultLocalLang),
|
|
393
396
|
status11.SERVICE_UNAVAILABLE
|
|
394
397
|
);
|
|
395
398
|
this.logger.error(
|
|
396
399
|
this.stackTrace.message,
|
|
397
|
-
TranslationLoader2.t("exited",
|
|
400
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
398
401
|
this.stackTrace.name,
|
|
399
402
|
this.stackTrace.stack,
|
|
400
403
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -402,13 +405,13 @@ var ServerListenEventError = class {
|
|
|
402
405
|
break;
|
|
403
406
|
case 137:
|
|
404
407
|
this.stackTrace = this.traceError(
|
|
405
|
-
TranslationLoader2.t("processEndedBySIGKILL",
|
|
408
|
+
TranslationLoader2.t("processEndedBySIGKILL", defaultLocalLang),
|
|
406
409
|
"SIGKILL",
|
|
407
410
|
status11.SERVICE_UNAVAILABLE
|
|
408
411
|
);
|
|
409
412
|
this.logger.error(
|
|
410
413
|
this.stackTrace.message,
|
|
411
|
-
TranslationLoader2.t("exited",
|
|
414
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
412
415
|
this.stackTrace.name,
|
|
413
416
|
this.stackTrace.stack,
|
|
414
417
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -416,13 +419,13 @@ var ServerListenEventError = class {
|
|
|
416
419
|
break;
|
|
417
420
|
case 139:
|
|
418
421
|
this.stackTrace = this.traceError(
|
|
419
|
-
TranslationLoader2.t("accessProcessIllegally",
|
|
420
|
-
TranslationLoader2.t("defaultSegment",
|
|
422
|
+
TranslationLoader2.t("accessProcessIllegally", defaultLocalLang),
|
|
423
|
+
TranslationLoader2.t("defaultSegment", defaultLocalLang),
|
|
421
424
|
status11.SERVICE_UNAVAILABLE
|
|
422
425
|
);
|
|
423
426
|
this.logger.error(
|
|
424
427
|
this.stackTrace.message,
|
|
425
|
-
TranslationLoader2.t("exited",
|
|
428
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
426
429
|
this.stackTrace.name,
|
|
427
430
|
this.stackTrace.stack,
|
|
428
431
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -430,13 +433,13 @@ var ServerListenEventError = class {
|
|
|
430
433
|
break;
|
|
431
434
|
case 143:
|
|
432
435
|
this.stackTrace = this.traceError(
|
|
433
|
-
TranslationLoader2.t("processReceivedSigtermSignal",
|
|
434
|
-
TranslationLoader2.t("processReceived",
|
|
436
|
+
TranslationLoader2.t("processReceivedSigtermSignal", defaultLocalLang),
|
|
437
|
+
TranslationLoader2.t("processReceived", defaultLocalLang),
|
|
435
438
|
status11.SERVICE_UNAVAILABLE
|
|
436
439
|
);
|
|
437
440
|
this.logger.error(
|
|
438
441
|
this.stackTrace.message,
|
|
439
|
-
TranslationLoader2.t("exited",
|
|
442
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
440
443
|
this.stackTrace.name,
|
|
441
444
|
this.stackTrace.stack,
|
|
442
445
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -444,13 +447,13 @@ var ServerListenEventError = class {
|
|
|
444
447
|
break;
|
|
445
448
|
case 255:
|
|
446
449
|
this.stackTrace = this.traceError(
|
|
447
|
-
TranslationLoader2.t("exitCode",
|
|
448
|
-
TranslationLoader2.t("outRange",
|
|
450
|
+
TranslationLoader2.t("exitCode", defaultLocalLang),
|
|
451
|
+
TranslationLoader2.t("outRange", defaultLocalLang),
|
|
449
452
|
status11.SERVICE_UNAVAILABLE
|
|
450
453
|
);
|
|
451
454
|
this.logger.error(
|
|
452
455
|
this.stackTrace.message,
|
|
453
|
-
TranslationLoader2.t("exited",
|
|
456
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
454
457
|
this.stackTrace.name,
|
|
455
458
|
this.stackTrace.stack,
|
|
456
459
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -458,13 +461,13 @@ var ServerListenEventError = class {
|
|
|
458
461
|
break;
|
|
459
462
|
default:
|
|
460
463
|
this.stackTrace = this.traceError(
|
|
461
|
-
TranslationLoader2.t("errorOccurring",
|
|
462
|
-
TranslationLoader2.t("errors",
|
|
464
|
+
TranslationLoader2.t("errorOccurring", defaultLocalLang),
|
|
465
|
+
TranslationLoader2.t("errors", defaultLocalLang),
|
|
463
466
|
status11.SERVICE_UNAVAILABLE
|
|
464
467
|
);
|
|
465
468
|
this.logger.error(
|
|
466
469
|
this.stackTrace.message,
|
|
467
|
-
TranslationLoader2.t("exited",
|
|
470
|
+
TranslationLoader2.t("exited", defaultLocalLang),
|
|
468
471
|
this.stackTrace.name,
|
|
469
472
|
this.stackTrace.stack,
|
|
470
473
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -475,12 +478,13 @@ var ServerListenEventError = class {
|
|
|
475
478
|
/**
|
|
476
479
|
*
|
|
477
480
|
* @param promise
|
|
481
|
+
* @param defaultLocalLang
|
|
478
482
|
*/
|
|
479
|
-
static promiseRejectionHandled(promise) {
|
|
483
|
+
static promiseRejectionHandled(promise, defaultLocalLang) {
|
|
480
484
|
try {
|
|
481
485
|
this.stackTrace = this.traceError(
|
|
482
|
-
TranslationLoader2.t("promise",
|
|
483
|
-
TranslationLoader2.t("rejectionPromise",
|
|
486
|
+
TranslationLoader2.t("promise", defaultLocalLang, { promise }),
|
|
487
|
+
TranslationLoader2.t("rejectionPromise", defaultLocalLang, { promise }),
|
|
484
488
|
status11.SERVICE_UNAVAILABLE
|
|
485
489
|
);
|
|
486
490
|
this.logger.error(
|
|
@@ -496,14 +500,15 @@ var ServerListenEventError = class {
|
|
|
496
500
|
/**
|
|
497
501
|
*
|
|
498
502
|
* @param error
|
|
503
|
+
* @param defaultLocalLang
|
|
499
504
|
*/
|
|
500
|
-
static uncaughtException(error) {
|
|
505
|
+
static uncaughtException(error, defaultLocalLang) {
|
|
501
506
|
if (error.message === "'app.router' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.") {
|
|
502
507
|
console.log("");
|
|
503
508
|
} else {
|
|
504
509
|
this.stackTrace = this.traceError(
|
|
505
|
-
TranslationLoader2.t(error.message),
|
|
506
|
-
TranslationLoader2.t("uncaughtExceptionHandled",
|
|
510
|
+
TranslationLoader2.t(error.message, defaultLocalLang),
|
|
511
|
+
TranslationLoader2.t("uncaughtExceptionHandled", defaultLocalLang),
|
|
507
512
|
status11.SERVICE_UNAVAILABLE
|
|
508
513
|
);
|
|
509
514
|
this.logger.error(
|
|
@@ -528,11 +533,12 @@ var ServerListenEventError = class {
|
|
|
528
533
|
*
|
|
529
534
|
* @param reason
|
|
530
535
|
* @param promise
|
|
536
|
+
* @param defaultLocalLang
|
|
531
537
|
*/
|
|
532
|
-
static unhandledRejection(reason, promise) {
|
|
538
|
+
static unhandledRejection(reason, promise, defaultLocalLang) {
|
|
533
539
|
this.stackTrace = this.traceError(
|
|
534
|
-
TranslationLoader2.t("unhandledRejectionAtPromise",
|
|
535
|
-
TranslationLoader2.t("unhandledRejection",
|
|
540
|
+
TranslationLoader2.t("unhandledRejectionAtPromise", defaultLocalLang, { promise, reason }),
|
|
541
|
+
TranslationLoader2.t("unhandledRejection", defaultLocalLang, { promise, reason }),
|
|
536
542
|
status11.SERVICE_UNAVAILABLE
|
|
537
543
|
);
|
|
538
544
|
this.logger.error(
|
|
@@ -546,16 +552,17 @@ var ServerListenEventError = class {
|
|
|
546
552
|
/**
|
|
547
553
|
*
|
|
548
554
|
* @param warning
|
|
555
|
+
* @param defaultLocalLang
|
|
549
556
|
*/
|
|
550
|
-
static warning(warning) {
|
|
557
|
+
static warning(warning, defaultLocalLang) {
|
|
551
558
|
this.stackTrace = this.traceError(
|
|
552
|
-
TranslationLoader2.t(warning.message,
|
|
559
|
+
TranslationLoader2.t(warning.message, defaultLocalLang),
|
|
553
560
|
"warning",
|
|
554
561
|
status11.SERVICE_UNAVAILABLE
|
|
555
562
|
);
|
|
556
563
|
this.logger.error(
|
|
557
564
|
this.stackTrace.message,
|
|
558
|
-
TranslationLoader2.t("warning",
|
|
565
|
+
TranslationLoader2.t("warning", defaultLocalLang, { warning }),
|
|
559
566
|
this.stackTrace.name,
|
|
560
567
|
this.stackTrace.stack,
|
|
561
568
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -564,11 +571,12 @@ var ServerListenEventError = class {
|
|
|
564
571
|
/**
|
|
565
572
|
*
|
|
566
573
|
* @param message
|
|
574
|
+
* @param defaultLocalLang
|
|
567
575
|
*/
|
|
568
|
-
static message(message) {
|
|
576
|
+
static message(message, defaultLocalLang) {
|
|
569
577
|
this.stackTrace = this.traceError(
|
|
570
|
-
TranslationLoader2.t("processGotMsg",
|
|
571
|
-
TranslationLoader2.t("msgException",
|
|
578
|
+
TranslationLoader2.t("processGotMsg", defaultLocalLang, { message }),
|
|
579
|
+
TranslationLoader2.t("msgException", defaultLocalLang, { message }),
|
|
572
580
|
status11.SERVICE_UNAVAILABLE
|
|
573
581
|
);
|
|
574
582
|
this.logger.error(
|
|
@@ -584,11 +592,12 @@ var ServerListenEventError = class {
|
|
|
584
592
|
* @param type
|
|
585
593
|
* @param promise
|
|
586
594
|
* @param reason
|
|
595
|
+
* @param defaultLocalLang
|
|
587
596
|
*/
|
|
588
|
-
static multipleResolves(type, promise, reason) {
|
|
597
|
+
static multipleResolves(type, promise, reason, defaultLocalLang) {
|
|
589
598
|
this.stackTrace = this.traceError(
|
|
590
|
-
TranslationLoader2.t("promiseReason",
|
|
591
|
-
TranslationLoader2.t("multipleResolvesDetected",
|
|
599
|
+
TranslationLoader2.t("promiseReason", defaultLocalLang, { promise, reason }),
|
|
600
|
+
TranslationLoader2.t("multipleResolvesDetected", defaultLocalLang, { type, promise, reason }),
|
|
592
601
|
status11.SERVICE_UNAVAILABLE
|
|
593
602
|
);
|
|
594
603
|
this.logger.error(
|
|
@@ -602,17 +611,18 @@ var ServerListenEventError = class {
|
|
|
602
611
|
/**
|
|
603
612
|
*
|
|
604
613
|
*/
|
|
605
|
-
static processInterrupted() {
|
|
606
|
-
this.logger.success(TranslationLoader2.t("okSuccess",
|
|
614
|
+
static processInterrupted(defaultLocalLang) {
|
|
615
|
+
this.logger.success(TranslationLoader2.t("okSuccess", defaultLocalLang), TranslationLoader2.t("serverWebStopped", defaultLocalLang));
|
|
607
616
|
process.exit(0);
|
|
608
617
|
}
|
|
609
618
|
/**
|
|
610
619
|
*
|
|
611
620
|
* @param signal
|
|
621
|
+
* @param defaultLocalLang
|
|
612
622
|
*/
|
|
613
|
-
static sigtermSignalReceived(signal) {
|
|
623
|
+
static sigtermSignalReceived(signal, defaultLocalLang) {
|
|
614
624
|
this.stackTrace = this.traceError(
|
|
615
|
-
TranslationLoader2.t("processPIDReceivedSignal",
|
|
625
|
+
TranslationLoader2.t("processPIDReceivedSignal", defaultLocalLang, { signal: signal.toString() }),
|
|
616
626
|
"SIGTERM",
|
|
617
627
|
status11.NOT_ACCEPTABLE
|
|
618
628
|
);
|
|
@@ -628,16 +638,16 @@ var ServerListenEventError = class {
|
|
|
628
638
|
/**
|
|
629
639
|
*
|
|
630
640
|
*/
|
|
631
|
-
static serverClosing() {
|
|
632
|
-
console.log(`${colors.bgCyanBright(` ${colors.bold(`${colors.white(` INFO `)}`)}`)} ${TranslationLoader2.t("allProcessStopped",
|
|
633
|
-
console.log(` ${TranslationLoader2.t("serverClosed",
|
|
641
|
+
static serverClosing(defaultLocalLang) {
|
|
642
|
+
console.log(`${colors.bgCyanBright(` ${colors.bold(`${colors.white(` INFO `)}`)}`)} ${TranslationLoader2.t("allProcessStopped", defaultLocalLang)}`);
|
|
643
|
+
console.log(` ${TranslationLoader2.t("serverClosed", defaultLocalLang)}`);
|
|
634
644
|
process.exit();
|
|
635
645
|
}
|
|
636
646
|
/**
|
|
637
647
|
*
|
|
638
648
|
*/
|
|
639
|
-
static dropNewConnection() {
|
|
640
|
-
console.log(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(` ${TranslationLoader2.t("serverMaxCon",
|
|
649
|
+
static dropNewConnection(defaultLocalLang) {
|
|
650
|
+
console.log(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(` ${TranslationLoader2.t("serverMaxCon", defaultLocalLang)} `)}`)} `)} ${dateTimeFormatted} | ${colors.bgCyan(`${colors.white(` Info `)}`)} ${TranslationLoader2.t("serverDroppedCon", defaultLocalLang)}`);
|
|
641
651
|
}
|
|
642
652
|
/**
|
|
643
653
|
*
|
|
@@ -646,29 +656,30 @@ var ServerListenEventError = class {
|
|
|
646
656
|
* @param req
|
|
647
657
|
* @param res
|
|
648
658
|
* @param next
|
|
659
|
+
* @param defaultLocalLang
|
|
649
660
|
*/
|
|
650
|
-
static expressErrorHandlingMiddleware(errorEmitter, err, req, res, next) {
|
|
661
|
+
static expressErrorHandlingMiddleware(errorEmitter, err, req, res, next, defaultLocalLang) {
|
|
651
662
|
if (err) {
|
|
652
663
|
errorEmitter.emit(CEventNameError.error, err);
|
|
653
664
|
if (typeof res.status === "function") {
|
|
654
|
-
res.status(500).send(TranslationLoader2.t("internalServerError",
|
|
665
|
+
res.status(500).send(TranslationLoader2.t("internalServerError", defaultLocalLang, { err }));
|
|
655
666
|
} else {
|
|
656
667
|
this.logger.error(
|
|
657
|
-
TranslationLoader2.t("resStatusNotFunc",
|
|
668
|
+
TranslationLoader2.t("resStatusNotFunc", defaultLocalLang, { err }),
|
|
658
669
|
"response status",
|
|
659
|
-
TranslationLoader2.t("respndNotFunc",
|
|
670
|
+
TranslationLoader2.t("respndNotFunc", defaultLocalLang, { err }),
|
|
660
671
|
err.stack,
|
|
661
672
|
status11.NOT_ACCEPTABLE
|
|
662
673
|
);
|
|
663
674
|
}
|
|
664
675
|
this.stackTrace = this.traceError(
|
|
665
676
|
err.message,
|
|
666
|
-
TranslationLoader2.t("expressError",
|
|
677
|
+
TranslationLoader2.t("expressError", defaultLocalLang, { err }),
|
|
667
678
|
status11.NOT_ACCEPTABLE
|
|
668
679
|
);
|
|
669
680
|
this.logger.error(
|
|
670
681
|
this.stackTrace.message,
|
|
671
|
-
TranslationLoader2.t("expressErrorHandlingMiddleware",
|
|
682
|
+
TranslationLoader2.t("expressErrorHandlingMiddleware", defaultLocalLang, { err }),
|
|
672
683
|
this.stackTrace.name,
|
|
673
684
|
this.stackTrace.stack,
|
|
674
685
|
status11.SERVICE_UNAVAILABLE
|
package/example/index.ts
CHANGED
|
@@ -15,6 +15,6 @@ console.log("__filename is : ", __filename);
|
|
|
15
15
|
// Obtenir le répertoire du fichier
|
|
16
16
|
(() => {
|
|
17
17
|
const __dirname = path.dirname(__filename);
|
|
18
|
-
const server = ServerListenEventError
|
|
19
|
-
server.hostPortUndefined();
|
|
18
|
+
const server = ServerListenEventError;
|
|
19
|
+
server.hostPortUndefined("en");
|
|
20
20
|
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opticore-catch-exception-error",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "opticore catch exception error",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"chalk": "^5.4.1",
|
|
29
29
|
"opticore-express": "^1.0.3",
|
|
30
30
|
"opticore-http-response": "^1.0.3",
|
|
31
|
-
"opticore-translator": "^1.0.
|
|
31
|
+
"opticore-translator": "^1.0.7",
|
|
32
32
|
"tsx": "^4.19.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"errorHostUrl": "The host and port are not define, please define them in .env",
|
|
3
|
-
"listening": "listening",
|
|
4
|
-
"webServer": "Web server",
|
|
5
|
-
"webHost": "host",
|
|
6
|
-
"hostNotFound": "not found",
|
|
7
|
-
"badHost": "bad host {badHost}",
|
|
8
|
-
"badPort": "bad port {badPort}",
|
|
9
|
-
"errorPort": "The port is not correct. Please define a right port with number port.",
|
|
10
|
-
"errorHost": "The host can't be empty or blank. Please define a string host in .env",
|
|
11
|
-
"serverStart": "Server start",
|
|
12
|
-
"serverStartError": "Server start with error {err}",
|
|
13
|
-
"processExitCode": "Process will exit with code: {code}",
|
|
14
|
-
"beforeExit": "BeforeExit",
|
|
15
|
-
"childProcessDiscon": "Child process disconnected",
|
|
16
|
-
"processDiscon": "process disconnected",
|
|
17
|
-
"completed": "completed with code {code}",
|
|
18
|
-
"finishingProcessWell": "The process is finishing well with code {code}",
|
|
19
|
-
"serverStopped": "[OK] The server shutting down",
|
|
20
|
-
"somethingWentWrong": "Something went wrong",
|
|
21
|
-
"genErrors": "General Errors",
|
|
22
|
-
"exited": "Exited",
|
|
23
|
-
"incorrectCmd": "Incorrect using of shell commands",
|
|
24
|
-
"misuseShell": "Misuse of shell builtins",
|
|
25
|
-
"cmdNotExecutable": "The command is found but is not executable (e.g., trying to execute a directory)",
|
|
26
|
-
"cmdNotFound": "Command not found",
|
|
27
|
-
"cmdNotFoundInSystemPath": "The command was not found in the system's PATH or is misspelled",
|
|
28
|
-
"argInvalid": "Invalid argument",
|
|
29
|
-
"scriptEndedManuallyByCtrlC": "Indicates that the script was manually terminated by the user using the Control-C (SIGINT) signal",
|
|
30
|
-
"scriptEnded": "Script terminated",
|
|
31
|
-
"processEndedBySIGKILL": "Indicates that the process was terminated by a SIGKILL signal, possibly due to an out-of-memory situation",
|
|
32
|
-
"accessProcessIllegally": "Indicates that the process accessed an illegal memory address (segfault)",
|
|
33
|
-
"defaultSegment": "Segmentation fault",
|
|
34
|
-
"processReceivedSigtermSignal": "Indicates that the process received a SIGTERM signal to terminate",
|
|
35
|
-
"processReceived": "process received a SIGTERM",
|
|
36
|
-
"exitCode": "An exit code that is outside the allowable range (0-255 for Unix-like systems)",
|
|
37
|
-
"outRange": "out of range",
|
|
38
|
-
"errorOccurring": "Error is occurring",
|
|
39
|
-
"errors": "errors",
|
|
40
|
-
"warning": "Warning {warning}",
|
|
41
|
-
"promiseRejectionHandled": "Promise rejection is handled at : {promise}",
|
|
42
|
-
"rejectionPromise": "rejection promise {promise}",
|
|
43
|
-
"uncaughtExceptionHandled": "uncaught exception handled",
|
|
44
|
-
"unhandledRejectionAtPromise": "Unhandled Rejection at: Promise {promise} -- reason {reason}",
|
|
45
|
-
"unhandledRejection": "Unhandled rejection at: Promise {promise} -- reason {reason}",
|
|
46
|
-
"processGotMsg": "process got message {message}",
|
|
47
|
-
"msgException": "message exception {}",
|
|
48
|
-
"promiseReason": "{promise} -- {reason}",
|
|
49
|
-
"multipleResolvesDetected": "Multiple resolves detected : {type}",
|
|
50
|
-
"okSuccess": "[ OK ] Success",
|
|
51
|
-
"processPIDReceivedSignal": "Process ${process.pid} received a SIGTERM signal : {signal} {promise} -- {reason}",
|
|
52
|
-
"allProcessStopped": "All processes are stopped",
|
|
53
|
-
"internalServerError": "Internal Server Error : {err}",
|
|
54
|
-
"resStatusNotFunc": "res.status is not a function {err}",
|
|
55
|
-
"respndNotFunc": "response not Function {err}",
|
|
56
|
-
"expressErrorHandlingMiddleware": "Express error-handling middleware {err}",
|
|
57
|
-
"expressError": "Express error {err}"
|
|
58
|
-
}
|