opticore-catch-exception-error 1.0.6 → 1.0.8
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 +106 -94
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +102 -92
- package/example/index.ts +20 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -44,11 +44,14 @@ __export(index_exports, {
|
|
|
44
44
|
StackTraceSyntaxError: () => StackTraceSyntaxError,
|
|
45
45
|
StackTraceSystemError: () => StackTraceSystemError,
|
|
46
46
|
StackTraceTypeError: () => StackTraceTypeError,
|
|
47
|
-
StackTraceURIError: () => StackTraceURIError
|
|
48
|
-
translateCatchExceptionErrorLanguageLoader: () => translateCatchExceptionErrorLanguageLoader
|
|
47
|
+
StackTraceURIError: () => StackTraceURIError
|
|
49
48
|
});
|
|
50
49
|
module.exports = __toCommonJS(index_exports);
|
|
51
50
|
|
|
51
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
52
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
53
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
54
|
+
|
|
52
55
|
// src/domains/constants/errorName.constant.ts
|
|
53
56
|
var CErrorName = {
|
|
54
57
|
evalError: "EvalError",
|
|
@@ -196,27 +199,45 @@ var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
|
196
199
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
197
200
|
var import_opticore_logger = require("opticore-logger");
|
|
198
201
|
var import_opticore_http_response11 = require("opticore-http-response");
|
|
199
|
-
var
|
|
202
|
+
var import_opticore_translator2 = require("opticore-translator");
|
|
200
203
|
|
|
201
204
|
// src/utils/dateTimeFormatted.utils.ts
|
|
202
205
|
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()}`;
|
|
203
206
|
|
|
204
207
|
// src/core/errors/events/serverListen.event.error.ts
|
|
208
|
+
var import_opticore_env_access2 = require("opticore-env-access");
|
|
209
|
+
|
|
210
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
211
|
+
var import_path = __toESM(require("path"), 1);
|
|
212
|
+
var import_opticore_translator = require("opticore-translator");
|
|
205
213
|
var import_opticore_env_access = require("opticore-env-access");
|
|
214
|
+
var import_url = require("url");
|
|
215
|
+
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
216
|
+
const __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
217
|
+
const __dirname = import_path.default.dirname(__filename2);
|
|
218
|
+
const translateMsgJsonFilePath = import_path.default.join(__dirname, "../../../", "utils", "translations");
|
|
219
|
+
import_opticore_translator.TranslationLoader.loadTranslations(translateMsgJsonFilePath, import_opticore_env_access.getEnvVariable.defaultLocal);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// src/core/errors/events/serverListen.event.error.ts
|
|
206
223
|
var ServerListenEventError = class {
|
|
224
|
+
static __init() {
|
|
225
|
+
translateCatchExceptionErrorLanguageLoader();
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
207
228
|
/**
|
|
208
229
|
*
|
|
209
230
|
*/
|
|
210
231
|
static hostPortUndefined() {
|
|
211
232
|
this.stackTrace = this.traceError(
|
|
212
|
-
|
|
213
|
-
|
|
233
|
+
import_opticore_translator2.TranslationLoader.t("errorHostUrl", import_opticore_translator2.CLocal),
|
|
234
|
+
import_opticore_translator2.TranslationLoader.t("listening", import_opticore_translator2.CLocal),
|
|
214
235
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
215
236
|
);
|
|
216
237
|
this.logger.error(
|
|
217
238
|
this.stackTrace.message,
|
|
218
|
-
|
|
219
|
-
|
|
239
|
+
import_opticore_translator2.TranslationLoader.t("webServer", import_opticore_translator2.CLocal),
|
|
240
|
+
import_opticore_translator2.TranslationLoader.t("badPort", import_opticore_translator2.CLocal, { badPort: import_opticore_env_access2.getEnvVariable.appPort }),
|
|
220
241
|
this.stackTrace.stack,
|
|
221
242
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
222
243
|
);
|
|
@@ -227,14 +248,14 @@ var ServerListenEventError = class {
|
|
|
227
248
|
*/
|
|
228
249
|
static hostUndefined() {
|
|
229
250
|
this.stackTrace = this.traceError(
|
|
230
|
-
|
|
231
|
-
|
|
251
|
+
import_opticore_translator2.TranslationLoader.t("badHost", import_opticore_translator2.CLocal, { badHost: import_opticore_env_access2.getEnvVariable.appHost }),
|
|
252
|
+
import_opticore_translator2.TranslationLoader.t("listening", import_opticore_translator2.CLocal),
|
|
232
253
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
233
254
|
);
|
|
234
255
|
this.logger.error(
|
|
235
256
|
this.stackTrace.message,
|
|
236
|
-
|
|
237
|
-
|
|
257
|
+
import_opticore_translator2.TranslationLoader.t("webServer", import_opticore_translator2.CLocal),
|
|
258
|
+
import_opticore_translator2.TranslationLoader.t("badHost", import_opticore_translator2.CLocal),
|
|
238
259
|
this.stackTrace.stack,
|
|
239
260
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
240
261
|
);
|
|
@@ -245,14 +266,14 @@ var ServerListenEventError = class {
|
|
|
245
266
|
*/
|
|
246
267
|
static portUndefined() {
|
|
247
268
|
this.stackTrace = this.traceError(
|
|
248
|
-
|
|
249
|
-
|
|
269
|
+
import_opticore_translator2.TranslationLoader.t("badPort", import_opticore_translator2.CLocal),
|
|
270
|
+
import_opticore_translator2.TranslationLoader.t("listening", import_opticore_translator2.CLocal),
|
|
250
271
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
251
272
|
);
|
|
252
273
|
this.logger.error(
|
|
253
274
|
this.stackTrace.message,
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
import_opticore_translator2.TranslationLoader.t("webServer", import_opticore_translator2.CLocal),
|
|
276
|
+
import_opticore_translator2.TranslationLoader.t("badHost", import_opticore_translator2.CLocal),
|
|
256
277
|
this.stackTrace.stack,
|
|
257
278
|
import_opticore_http_response11.HttpStatusCode.BAD_REQUEST
|
|
258
279
|
);
|
|
@@ -264,9 +285,9 @@ var ServerListenEventError = class {
|
|
|
264
285
|
*/
|
|
265
286
|
static onEventError(err) {
|
|
266
287
|
this.logger.error(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
288
|
+
import_opticore_translator2.TranslationLoader.t(err.message, import_opticore_translator2.CLocal),
|
|
289
|
+
import_opticore_translator2.TranslationLoader.t("serverStart", import_opticore_translator2.CLocal),
|
|
290
|
+
import_opticore_translator2.TranslationLoader.t("serverStartError", import_opticore_translator2.CLocal, { err }),
|
|
270
291
|
err.stack,
|
|
271
292
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
272
293
|
);
|
|
@@ -295,14 +316,14 @@ var ServerListenEventError = class {
|
|
|
295
316
|
*/
|
|
296
317
|
static processBeforeExit(code) {
|
|
297
318
|
this.stackTrace = this.traceError(
|
|
298
|
-
|
|
299
|
-
|
|
319
|
+
import_opticore_translator2.TranslationLoader.t("processExitCode", import_opticore_translator2.CLocal, { processExitCode: code }),
|
|
320
|
+
import_opticore_translator2.TranslationLoader.t("beforeExit", import_opticore_translator2.CLocal),
|
|
300
321
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
301
322
|
);
|
|
302
323
|
this.logger.error(
|
|
303
324
|
this.stackTrace.message,
|
|
304
|
-
|
|
305
|
-
|
|
325
|
+
import_opticore_translator2.TranslationLoader.t("beforeExit", import_opticore_translator2.CLocal),
|
|
326
|
+
import_opticore_translator2.TranslationLoader.t("processBeforeExit", import_opticore_translator2.CLocal),
|
|
306
327
|
this.stackTrace.stack,
|
|
307
328
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
308
329
|
);
|
|
@@ -313,14 +334,14 @@ var ServerListenEventError = class {
|
|
|
313
334
|
*/
|
|
314
335
|
static processDisconnected() {
|
|
315
336
|
this.stackTrace = this.traceError(
|
|
316
|
-
|
|
317
|
-
|
|
337
|
+
import_opticore_translator2.TranslationLoader.t("childProcessDiscon", import_opticore_translator2.CLocal),
|
|
338
|
+
import_opticore_translator2.TranslationLoader.t("processDiscon", import_opticore_translator2.CLocal),
|
|
318
339
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
319
340
|
);
|
|
320
341
|
this.logger.error(
|
|
321
342
|
this.stackTrace.message,
|
|
322
|
-
|
|
323
|
-
|
|
343
|
+
import_opticore_translator2.TranslationLoader.t("disconnected"),
|
|
344
|
+
import_opticore_translator2.TranslationLoader.t("processDiscon"),
|
|
324
345
|
this.stackTrace.stack,
|
|
325
346
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
326
347
|
);
|
|
@@ -334,25 +355,25 @@ var ServerListenEventError = class {
|
|
|
334
355
|
switch (code) {
|
|
335
356
|
case 0:
|
|
336
357
|
this.logger.success(
|
|
337
|
-
|
|
338
|
-
|
|
358
|
+
import_opticore_translator2.TranslationLoader.t("completed", import_opticore_translator2.CLocal, { code }),
|
|
359
|
+
import_opticore_translator2.TranslationLoader.t("finishingProcessWell", import_opticore_translator2.CLocal, { code })
|
|
339
360
|
);
|
|
340
361
|
console.log("");
|
|
341
362
|
const paddingLength = 35;
|
|
342
363
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
343
364
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
344
|
-
console.log(`${import_ansi_colors.default.bgGreen(` ${
|
|
365
|
+
console.log(`${import_ansi_colors.default.bgGreen(` ${import_opticore_translator2.TranslationLoader.t("serverStopped", import_opticore_translator2.CLocal)} `)}`);
|
|
345
366
|
console.log(import_chalk.default.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
346
367
|
break;
|
|
347
368
|
case 1:
|
|
348
369
|
this.stackTrace = this.traceError(
|
|
349
|
-
|
|
350
|
-
|
|
370
|
+
import_opticore_translator2.TranslationLoader.t("somethingWentWrong", import_opticore_translator2.CLocal),
|
|
371
|
+
import_opticore_translator2.TranslationLoader.t("genErrors", import_opticore_translator2.CLocal),
|
|
351
372
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
352
373
|
);
|
|
353
374
|
this.logger.error(
|
|
354
375
|
this.stackTrace.message,
|
|
355
|
-
|
|
376
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
356
377
|
"General Errors",
|
|
357
378
|
this.stackTrace.stack,
|
|
358
379
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -360,27 +381,27 @@ var ServerListenEventError = class {
|
|
|
360
381
|
break;
|
|
361
382
|
case 2:
|
|
362
383
|
this.stackTrace = this.traceError(
|
|
363
|
-
|
|
364
|
-
|
|
384
|
+
import_opticore_translator2.TranslationLoader.t("incorrectCmd", import_opticore_translator2.CLocal),
|
|
385
|
+
import_opticore_translator2.TranslationLoader.t("misuseShell", import_opticore_translator2.CLocal),
|
|
365
386
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
366
387
|
);
|
|
367
388
|
this.logger.error(
|
|
368
389
|
this.stackTrace.message,
|
|
369
|
-
|
|
370
|
-
|
|
390
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
391
|
+
import_opticore_translator2.TranslationLoader.t("incorrectCmd", import_opticore_translator2.CLocal),
|
|
371
392
|
this.stackTrace.stack,
|
|
372
393
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
373
394
|
);
|
|
374
395
|
break;
|
|
375
396
|
case 126:
|
|
376
397
|
this.stackTrace = this.traceError(
|
|
377
|
-
|
|
378
|
-
|
|
398
|
+
import_opticore_translator2.TranslationLoader.t("incorrectCmd", import_opticore_translator2.CLocal),
|
|
399
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotExecutable", import_opticore_translator2.CLocal),
|
|
379
400
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
380
401
|
);
|
|
381
402
|
this.logger.error(
|
|
382
403
|
this.stackTrace.message,
|
|
383
|
-
|
|
404
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
384
405
|
this.stackTrace.name,
|
|
385
406
|
this.stackTrace.stack,
|
|
386
407
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -388,13 +409,13 @@ var ServerListenEventError = class {
|
|
|
388
409
|
break;
|
|
389
410
|
case 127:
|
|
390
411
|
this.stackTrace = this.traceError(
|
|
391
|
-
|
|
392
|
-
|
|
412
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotFound", import_opticore_translator2.CLocal),
|
|
413
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotFoundInSystemPath", import_opticore_translator2.CLocal),
|
|
393
414
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
394
415
|
);
|
|
395
416
|
this.logger.error(
|
|
396
417
|
this.stackTrace.message,
|
|
397
|
-
|
|
418
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
398
419
|
this.stackTrace.name,
|
|
399
420
|
this.stackTrace.stack,
|
|
400
421
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -402,13 +423,13 @@ var ServerListenEventError = class {
|
|
|
402
423
|
break;
|
|
403
424
|
case 128:
|
|
404
425
|
this.stackTrace = this.traceError(
|
|
405
|
-
|
|
406
|
-
|
|
426
|
+
import_opticore_translator2.TranslationLoader.t("cmdNotFoundInSystemPath", import_opticore_translator2.CLocal),
|
|
427
|
+
import_opticore_translator2.TranslationLoader.t("argInvalid", import_opticore_translator2.CLocal),
|
|
407
428
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
408
429
|
);
|
|
409
430
|
this.logger.error(
|
|
410
431
|
this.stackTrace.message,
|
|
411
|
-
|
|
432
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
412
433
|
this.stackTrace.name,
|
|
413
434
|
this.stackTrace.stack,
|
|
414
435
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -416,13 +437,13 @@ var ServerListenEventError = class {
|
|
|
416
437
|
break;
|
|
417
438
|
case 130:
|
|
418
439
|
this.stackTrace = this.traceError(
|
|
419
|
-
|
|
420
|
-
|
|
440
|
+
import_opticore_translator2.TranslationLoader.t("scriptEndedManuallyByCtrlC", import_opticore_translator2.CLocal),
|
|
441
|
+
import_opticore_translator2.TranslationLoader.t("scriptEnded", import_opticore_translator2.CLocal),
|
|
421
442
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
422
443
|
);
|
|
423
444
|
this.logger.error(
|
|
424
445
|
this.stackTrace.message,
|
|
425
|
-
|
|
446
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
426
447
|
this.stackTrace.name,
|
|
427
448
|
this.stackTrace.stack,
|
|
428
449
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -430,13 +451,13 @@ var ServerListenEventError = class {
|
|
|
430
451
|
break;
|
|
431
452
|
case 137:
|
|
432
453
|
this.stackTrace = this.traceError(
|
|
433
|
-
|
|
454
|
+
import_opticore_translator2.TranslationLoader.t("processEndedBySIGKILL", import_opticore_translator2.CLocal),
|
|
434
455
|
"SIGKILL",
|
|
435
456
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
436
457
|
);
|
|
437
458
|
this.logger.error(
|
|
438
459
|
this.stackTrace.message,
|
|
439
|
-
|
|
460
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
440
461
|
this.stackTrace.name,
|
|
441
462
|
this.stackTrace.stack,
|
|
442
463
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -444,13 +465,13 @@ var ServerListenEventError = class {
|
|
|
444
465
|
break;
|
|
445
466
|
case 139:
|
|
446
467
|
this.stackTrace = this.traceError(
|
|
447
|
-
|
|
448
|
-
|
|
468
|
+
import_opticore_translator2.TranslationLoader.t("accessProcessIllegally", import_opticore_translator2.CLocal),
|
|
469
|
+
import_opticore_translator2.TranslationLoader.t("defaultSegment", import_opticore_translator2.CLocal),
|
|
449
470
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
450
471
|
);
|
|
451
472
|
this.logger.error(
|
|
452
473
|
this.stackTrace.message,
|
|
453
|
-
|
|
474
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
454
475
|
this.stackTrace.name,
|
|
455
476
|
this.stackTrace.stack,
|
|
456
477
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -458,13 +479,13 @@ var ServerListenEventError = class {
|
|
|
458
479
|
break;
|
|
459
480
|
case 143:
|
|
460
481
|
this.stackTrace = this.traceError(
|
|
461
|
-
|
|
462
|
-
|
|
482
|
+
import_opticore_translator2.TranslationLoader.t("processReceivedSigtermSignal", import_opticore_translator2.CLocal),
|
|
483
|
+
import_opticore_translator2.TranslationLoader.t("processReceived", import_opticore_translator2.CLocal),
|
|
463
484
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
464
485
|
);
|
|
465
486
|
this.logger.error(
|
|
466
487
|
this.stackTrace.message,
|
|
467
|
-
|
|
488
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
468
489
|
this.stackTrace.name,
|
|
469
490
|
this.stackTrace.stack,
|
|
470
491
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -472,13 +493,13 @@ var ServerListenEventError = class {
|
|
|
472
493
|
break;
|
|
473
494
|
case 255:
|
|
474
495
|
this.stackTrace = this.traceError(
|
|
475
|
-
|
|
476
|
-
|
|
496
|
+
import_opticore_translator2.TranslationLoader.t("exitCode", import_opticore_translator2.CLocal),
|
|
497
|
+
import_opticore_translator2.TranslationLoader.t("outRange", import_opticore_translator2.CLocal),
|
|
477
498
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
478
499
|
);
|
|
479
500
|
this.logger.error(
|
|
480
501
|
this.stackTrace.message,
|
|
481
|
-
|
|
502
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
482
503
|
this.stackTrace.name,
|
|
483
504
|
this.stackTrace.stack,
|
|
484
505
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -486,13 +507,13 @@ var ServerListenEventError = class {
|
|
|
486
507
|
break;
|
|
487
508
|
default:
|
|
488
509
|
this.stackTrace = this.traceError(
|
|
489
|
-
|
|
490
|
-
|
|
510
|
+
import_opticore_translator2.TranslationLoader.t("errorOccurring", import_opticore_translator2.CLocal),
|
|
511
|
+
import_opticore_translator2.TranslationLoader.t("errors", import_opticore_translator2.CLocal),
|
|
491
512
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
492
513
|
);
|
|
493
514
|
this.logger.error(
|
|
494
515
|
this.stackTrace.message,
|
|
495
|
-
|
|
516
|
+
import_opticore_translator2.TranslationLoader.t("exited", import_opticore_translator2.CLocal),
|
|
496
517
|
this.stackTrace.name,
|
|
497
518
|
this.stackTrace.stack,
|
|
498
519
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -507,8 +528,8 @@ var ServerListenEventError = class {
|
|
|
507
528
|
static promiseRejectionHandled(promise) {
|
|
508
529
|
try {
|
|
509
530
|
this.stackTrace = this.traceError(
|
|
510
|
-
|
|
511
|
-
|
|
531
|
+
import_opticore_translator2.TranslationLoader.t("promise", import_opticore_translator2.CLocal, { promise }),
|
|
532
|
+
import_opticore_translator2.TranslationLoader.t("rejectionPromise", import_opticore_translator2.CLocal, { promise }),
|
|
512
533
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
513
534
|
);
|
|
514
535
|
this.logger.error(
|
|
@@ -530,8 +551,8 @@ var ServerListenEventError = class {
|
|
|
530
551
|
console.log("");
|
|
531
552
|
} else {
|
|
532
553
|
this.stackTrace = this.traceError(
|
|
533
|
-
|
|
534
|
-
|
|
554
|
+
import_opticore_translator2.TranslationLoader.t(error.message),
|
|
555
|
+
import_opticore_translator2.TranslationLoader.t("uncaughtExceptionHandled", import_opticore_translator2.CLocal),
|
|
535
556
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
536
557
|
);
|
|
537
558
|
this.logger.error(
|
|
@@ -559,8 +580,8 @@ var ServerListenEventError = class {
|
|
|
559
580
|
*/
|
|
560
581
|
static unhandledRejection(reason, promise) {
|
|
561
582
|
this.stackTrace = this.traceError(
|
|
562
|
-
|
|
563
|
-
|
|
583
|
+
import_opticore_translator2.TranslationLoader.t("unhandledRejectionAtPromise", import_opticore_translator2.CLocal, { promise, reason }),
|
|
584
|
+
import_opticore_translator2.TranslationLoader.t("unhandledRejection", import_opticore_translator2.CLocal, { promise, reason }),
|
|
564
585
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
565
586
|
);
|
|
566
587
|
this.logger.error(
|
|
@@ -577,13 +598,13 @@ var ServerListenEventError = class {
|
|
|
577
598
|
*/
|
|
578
599
|
static warning(warning) {
|
|
579
600
|
this.stackTrace = this.traceError(
|
|
580
|
-
|
|
601
|
+
import_opticore_translator2.TranslationLoader.t(warning.message, import_opticore_translator2.CLocal),
|
|
581
602
|
"warning",
|
|
582
603
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
583
604
|
);
|
|
584
605
|
this.logger.error(
|
|
585
606
|
this.stackTrace.message,
|
|
586
|
-
|
|
607
|
+
import_opticore_translator2.TranslationLoader.t("warning", import_opticore_translator2.CLocal, { warning }),
|
|
587
608
|
this.stackTrace.name,
|
|
588
609
|
this.stackTrace.stack,
|
|
589
610
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -595,8 +616,8 @@ var ServerListenEventError = class {
|
|
|
595
616
|
*/
|
|
596
617
|
static message(message) {
|
|
597
618
|
this.stackTrace = this.traceError(
|
|
598
|
-
|
|
599
|
-
|
|
619
|
+
import_opticore_translator2.TranslationLoader.t("processGotMsg", import_opticore_translator2.CLocal, { message }),
|
|
620
|
+
import_opticore_translator2.TranslationLoader.t("msgException", import_opticore_translator2.CLocal, { message }),
|
|
600
621
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
601
622
|
);
|
|
602
623
|
this.logger.error(
|
|
@@ -615,8 +636,8 @@ var ServerListenEventError = class {
|
|
|
615
636
|
*/
|
|
616
637
|
static multipleResolves(type, promise, reason) {
|
|
617
638
|
this.stackTrace = this.traceError(
|
|
618
|
-
|
|
619
|
-
|
|
639
|
+
import_opticore_translator2.TranslationLoader.t("promiseReason", import_opticore_translator2.CLocal, { promise, reason }),
|
|
640
|
+
import_opticore_translator2.TranslationLoader.t("multipleResolvesDetected", import_opticore_translator2.CLocal, { type, promise, reason }),
|
|
620
641
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
621
642
|
);
|
|
622
643
|
this.logger.error(
|
|
@@ -631,7 +652,7 @@ var ServerListenEventError = class {
|
|
|
631
652
|
*
|
|
632
653
|
*/
|
|
633
654
|
static processInterrupted() {
|
|
634
|
-
this.logger.success(
|
|
655
|
+
this.logger.success(import_opticore_translator2.TranslationLoader.t("okSuccess", import_opticore_translator2.CLocal), import_opticore_translator2.TranslationLoader.t("serverWebStopped", import_opticore_translator2.CLocal));
|
|
635
656
|
import_process.default.exit(0);
|
|
636
657
|
}
|
|
637
658
|
/**
|
|
@@ -640,7 +661,7 @@ var ServerListenEventError = class {
|
|
|
640
661
|
*/
|
|
641
662
|
static sigtermSignalReceived(signal) {
|
|
642
663
|
this.stackTrace = this.traceError(
|
|
643
|
-
|
|
664
|
+
import_opticore_translator2.TranslationLoader.t("processPIDReceivedSignal", import_opticore_translator2.CLocal, { signal: signal.toString() }),
|
|
644
665
|
"SIGTERM",
|
|
645
666
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
646
667
|
);
|
|
@@ -657,15 +678,15 @@ var ServerListenEventError = class {
|
|
|
657
678
|
*
|
|
658
679
|
*/
|
|
659
680
|
static serverClosing() {
|
|
660
|
-
console.log(`${import_ansi_colors.default.bgCyanBright(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` INFO `)}`)}`)} ${
|
|
661
|
-
console.log(` ${
|
|
681
|
+
console.log(`${import_ansi_colors.default.bgCyanBright(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` INFO `)}`)}`)} ${import_opticore_translator2.TranslationLoader.t("allProcessStopped", import_opticore_translator2.CLocal)}`);
|
|
682
|
+
console.log(` ${import_opticore_translator2.TranslationLoader.t("serverClosed", import_opticore_translator2.CLocal)}`);
|
|
662
683
|
import_process.default.exit();
|
|
663
684
|
}
|
|
664
685
|
/**
|
|
665
686
|
*
|
|
666
687
|
*/
|
|
667
688
|
static dropNewConnection() {
|
|
668
|
-
console.log(`${import_ansi_colors.default.cyan(`\u24D8`)} ${import_ansi_colors.default.bgCyan(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` ${
|
|
689
|
+
console.log(`${import_ansi_colors.default.cyan(`\u24D8`)} ${import_ansi_colors.default.bgCyan(` ${import_ansi_colors.default.bold(`${import_ansi_colors.default.white(` ${import_opticore_translator2.TranslationLoader.t("serverMaxCon", import_opticore_translator2.CLocal)} `)}`)} `)} ${dateTimeFormatted} | ${import_ansi_colors.default.bgCyan(`${import_ansi_colors.default.white(` Info `)}`)} ${import_opticore_translator2.TranslationLoader.t("serverDroppedCon", import_opticore_translator2.CLocal)}`);
|
|
669
690
|
}
|
|
670
691
|
/**
|
|
671
692
|
*
|
|
@@ -679,24 +700,24 @@ var ServerListenEventError = class {
|
|
|
679
700
|
if (err) {
|
|
680
701
|
errorEmitter.emit(CEventNameError.error, err);
|
|
681
702
|
if (typeof res.status === "function") {
|
|
682
|
-
res.status(500).send(
|
|
703
|
+
res.status(500).send(import_opticore_translator2.TranslationLoader.t("internalServerError", import_opticore_translator2.CLocal, { err }));
|
|
683
704
|
} else {
|
|
684
705
|
this.logger.error(
|
|
685
|
-
|
|
706
|
+
import_opticore_translator2.TranslationLoader.t("resStatusNotFunc", import_opticore_translator2.CLocal, { err }),
|
|
686
707
|
"response status",
|
|
687
|
-
|
|
708
|
+
import_opticore_translator2.TranslationLoader.t("respndNotFunc", import_opticore_translator2.CLocal, { err }),
|
|
688
709
|
err.stack,
|
|
689
710
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
690
711
|
);
|
|
691
712
|
}
|
|
692
713
|
this.stackTrace = this.traceError(
|
|
693
714
|
err.message,
|
|
694
|
-
|
|
715
|
+
import_opticore_translator2.TranslationLoader.t("expressError", import_opticore_translator2.CLocal, { err }),
|
|
695
716
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
696
717
|
);
|
|
697
718
|
this.logger.error(
|
|
698
719
|
this.stackTrace.message,
|
|
699
|
-
|
|
720
|
+
import_opticore_translator2.TranslationLoader.t("expressErrorHandlingMiddleware", import_opticore_translator2.CLocal, { err }),
|
|
700
721
|
this.stackTrace.name,
|
|
701
722
|
this.stackTrace.stack,
|
|
702
723
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -710,14 +731,6 @@ var ServerListenEventError = class {
|
|
|
710
731
|
}
|
|
711
732
|
};
|
|
712
733
|
ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
|
|
713
|
-
|
|
714
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
715
|
-
var import_path = __toESM(require("path"), 1);
|
|
716
|
-
var import_opticore_translator2 = require("opticore-translator");
|
|
717
|
-
var import_opticore_env_access2 = require("opticore-env-access");
|
|
718
|
-
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
719
|
-
import_opticore_translator2.TranslationLoader.loadTranslations(import_path.default.join("src", "shared", "translations"), import_opticore_env_access2.getEnvVariable.defaultLocal);
|
|
720
|
-
};
|
|
721
734
|
// Annotate the CommonJS export names for ESM import in node:
|
|
722
735
|
0 && (module.exports = {
|
|
723
736
|
CErrorName,
|
|
@@ -734,6 +747,5 @@ var translateCatchExceptionErrorLanguageLoader = () => {
|
|
|
734
747
|
StackTraceSyntaxError,
|
|
735
748
|
StackTraceSystemError,
|
|
736
749
|
StackTraceTypeError,
|
|
737
|
-
StackTraceURIError
|
|
738
|
-
translateCatchExceptionErrorLanguageLoader
|
|
750
|
+
StackTraceURIError
|
|
739
751
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -130,6 +130,7 @@ declare class StackTraceURIError extends StackTraceError {
|
|
|
130
130
|
declare class ServerListenEventError {
|
|
131
131
|
private static logger;
|
|
132
132
|
private static stackTrace;
|
|
133
|
+
static __init(): typeof ServerListenEventError;
|
|
133
134
|
/**
|
|
134
135
|
*
|
|
135
136
|
*/
|
|
@@ -233,6 +234,4 @@ declare class ServerListenEventError {
|
|
|
233
234
|
private static traceError;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError, translateCatchExceptionErrorLanguageLoader };
|
|
237
|
+
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError };
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ declare class StackTraceURIError extends StackTraceError {
|
|
|
130
130
|
declare class ServerListenEventError {
|
|
131
131
|
private static logger;
|
|
132
132
|
private static stackTrace;
|
|
133
|
+
static __init(): typeof ServerListenEventError;
|
|
133
134
|
/**
|
|
134
135
|
*
|
|
135
136
|
*/
|
|
@@ -233,6 +234,4 @@ declare class ServerListenEventError {
|
|
|
233
234
|
private static traceError;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError, translateCatchExceptionErrorLanguageLoader };
|
|
237
|
+
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError };
|
package/dist/index.js
CHANGED
|
@@ -145,27 +145,46 @@ import colors from "ansi-colors";
|
|
|
145
145
|
import chalk from "chalk";
|
|
146
146
|
import { LoggerCore } from "opticore-logger";
|
|
147
147
|
import { HttpStatusCode as status11 } from "opticore-http-response";
|
|
148
|
-
import { CLocal, TranslationLoader } from "opticore-translator";
|
|
148
|
+
import { CLocal, TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
149
149
|
|
|
150
150
|
// src/utils/dateTimeFormatted.utils.ts
|
|
151
151
|
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()}`;
|
|
152
152
|
|
|
153
153
|
// src/core/errors/events/serverListen.event.error.ts
|
|
154
|
+
import { getEnvVariable as getEnvVariable2 } from "opticore-env-access";
|
|
155
|
+
|
|
156
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
157
|
+
import path from "path";
|
|
158
|
+
import { TranslationLoader } from "opticore-translator";
|
|
154
159
|
import { getEnvVariable } from "opticore-env-access";
|
|
160
|
+
import { fileURLToPath } from "url";
|
|
161
|
+
var import_meta = {};
|
|
162
|
+
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
163
|
+
const __filename2 = fileURLToPath(import_meta.url);
|
|
164
|
+
const __dirname2 = path.dirname(__filename2);
|
|
165
|
+
const translateMsgJsonFilePath = path.join(__dirname2, "../../../", "utils", "translations");
|
|
166
|
+
TranslationLoader.loadTranslations(translateMsgJsonFilePath, getEnvVariable.defaultLocal);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// src/core/errors/events/serverListen.event.error.ts
|
|
155
170
|
var ServerListenEventError = class {
|
|
171
|
+
static __init() {
|
|
172
|
+
translateCatchExceptionErrorLanguageLoader();
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
156
175
|
/**
|
|
157
176
|
*
|
|
158
177
|
*/
|
|
159
178
|
static hostPortUndefined() {
|
|
160
179
|
this.stackTrace = this.traceError(
|
|
161
|
-
|
|
162
|
-
|
|
180
|
+
TranslationLoader2.t("errorHostUrl", CLocal),
|
|
181
|
+
TranslationLoader2.t("listening", CLocal),
|
|
163
182
|
status11.BAD_REQUEST
|
|
164
183
|
);
|
|
165
184
|
this.logger.error(
|
|
166
185
|
this.stackTrace.message,
|
|
167
|
-
|
|
168
|
-
|
|
186
|
+
TranslationLoader2.t("webServer", CLocal),
|
|
187
|
+
TranslationLoader2.t("badPort", CLocal, { badPort: getEnvVariable2.appPort }),
|
|
169
188
|
this.stackTrace.stack,
|
|
170
189
|
status11.BAD_REQUEST
|
|
171
190
|
);
|
|
@@ -176,14 +195,14 @@ var ServerListenEventError = class {
|
|
|
176
195
|
*/
|
|
177
196
|
static hostUndefined() {
|
|
178
197
|
this.stackTrace = this.traceError(
|
|
179
|
-
|
|
180
|
-
|
|
198
|
+
TranslationLoader2.t("badHost", CLocal, { badHost: getEnvVariable2.appHost }),
|
|
199
|
+
TranslationLoader2.t("listening", CLocal),
|
|
181
200
|
status11.BAD_REQUEST
|
|
182
201
|
);
|
|
183
202
|
this.logger.error(
|
|
184
203
|
this.stackTrace.message,
|
|
185
|
-
|
|
186
|
-
|
|
204
|
+
TranslationLoader2.t("webServer", CLocal),
|
|
205
|
+
TranslationLoader2.t("badHost", CLocal),
|
|
187
206
|
this.stackTrace.stack,
|
|
188
207
|
status11.BAD_REQUEST
|
|
189
208
|
);
|
|
@@ -194,14 +213,14 @@ var ServerListenEventError = class {
|
|
|
194
213
|
*/
|
|
195
214
|
static portUndefined() {
|
|
196
215
|
this.stackTrace = this.traceError(
|
|
197
|
-
|
|
198
|
-
|
|
216
|
+
TranslationLoader2.t("badPort", CLocal),
|
|
217
|
+
TranslationLoader2.t("listening", CLocal),
|
|
199
218
|
status11.BAD_REQUEST
|
|
200
219
|
);
|
|
201
220
|
this.logger.error(
|
|
202
221
|
this.stackTrace.message,
|
|
203
|
-
|
|
204
|
-
|
|
222
|
+
TranslationLoader2.t("webServer", CLocal),
|
|
223
|
+
TranslationLoader2.t("badHost", CLocal),
|
|
205
224
|
this.stackTrace.stack,
|
|
206
225
|
status11.BAD_REQUEST
|
|
207
226
|
);
|
|
@@ -213,9 +232,9 @@ var ServerListenEventError = class {
|
|
|
213
232
|
*/
|
|
214
233
|
static onEventError(err) {
|
|
215
234
|
this.logger.error(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
235
|
+
TranslationLoader2.t(err.message, CLocal),
|
|
236
|
+
TranslationLoader2.t("serverStart", CLocal),
|
|
237
|
+
TranslationLoader2.t("serverStartError", CLocal, { err }),
|
|
219
238
|
err.stack,
|
|
220
239
|
status11.SERVICE_UNAVAILABLE
|
|
221
240
|
);
|
|
@@ -244,14 +263,14 @@ var ServerListenEventError = class {
|
|
|
244
263
|
*/
|
|
245
264
|
static processBeforeExit(code) {
|
|
246
265
|
this.stackTrace = this.traceError(
|
|
247
|
-
|
|
248
|
-
|
|
266
|
+
TranslationLoader2.t("processExitCode", CLocal, { processExitCode: code }),
|
|
267
|
+
TranslationLoader2.t("beforeExit", CLocal),
|
|
249
268
|
status11.SERVICE_UNAVAILABLE
|
|
250
269
|
);
|
|
251
270
|
this.logger.error(
|
|
252
271
|
this.stackTrace.message,
|
|
253
|
-
|
|
254
|
-
|
|
272
|
+
TranslationLoader2.t("beforeExit", CLocal),
|
|
273
|
+
TranslationLoader2.t("processBeforeExit", CLocal),
|
|
255
274
|
this.stackTrace.stack,
|
|
256
275
|
status11.SERVICE_UNAVAILABLE
|
|
257
276
|
);
|
|
@@ -262,14 +281,14 @@ var ServerListenEventError = class {
|
|
|
262
281
|
*/
|
|
263
282
|
static processDisconnected() {
|
|
264
283
|
this.stackTrace = this.traceError(
|
|
265
|
-
|
|
266
|
-
|
|
284
|
+
TranslationLoader2.t("childProcessDiscon", CLocal),
|
|
285
|
+
TranslationLoader2.t("processDiscon", CLocal),
|
|
267
286
|
status11.SERVICE_UNAVAILABLE
|
|
268
287
|
);
|
|
269
288
|
this.logger.error(
|
|
270
289
|
this.stackTrace.message,
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
TranslationLoader2.t("disconnected"),
|
|
291
|
+
TranslationLoader2.t("processDiscon"),
|
|
273
292
|
this.stackTrace.stack,
|
|
274
293
|
status11.SERVICE_UNAVAILABLE
|
|
275
294
|
);
|
|
@@ -283,25 +302,25 @@ var ServerListenEventError = class {
|
|
|
283
302
|
switch (code) {
|
|
284
303
|
case 0:
|
|
285
304
|
this.logger.success(
|
|
286
|
-
|
|
287
|
-
|
|
305
|
+
TranslationLoader2.t("completed", CLocal, { code }),
|
|
306
|
+
TranslationLoader2.t("finishingProcessWell", CLocal, { code })
|
|
288
307
|
);
|
|
289
308
|
console.log("");
|
|
290
309
|
const paddingLength = 35;
|
|
291
310
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
292
311
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
293
|
-
console.log(`${colors.bgGreen(` ${
|
|
312
|
+
console.log(`${colors.bgGreen(` ${TranslationLoader2.t("serverStopped", CLocal)} `)}`);
|
|
294
313
|
console.log(chalk.bgGreen.white(msg0.padEnd(paddingLength, " ")));
|
|
295
314
|
break;
|
|
296
315
|
case 1:
|
|
297
316
|
this.stackTrace = this.traceError(
|
|
298
|
-
|
|
299
|
-
|
|
317
|
+
TranslationLoader2.t("somethingWentWrong", CLocal),
|
|
318
|
+
TranslationLoader2.t("genErrors", CLocal),
|
|
300
319
|
status11.SERVICE_UNAVAILABLE
|
|
301
320
|
);
|
|
302
321
|
this.logger.error(
|
|
303
322
|
this.stackTrace.message,
|
|
304
|
-
|
|
323
|
+
TranslationLoader2.t("exited", CLocal),
|
|
305
324
|
"General Errors",
|
|
306
325
|
this.stackTrace.stack,
|
|
307
326
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -309,27 +328,27 @@ var ServerListenEventError = class {
|
|
|
309
328
|
break;
|
|
310
329
|
case 2:
|
|
311
330
|
this.stackTrace = this.traceError(
|
|
312
|
-
|
|
313
|
-
|
|
331
|
+
TranslationLoader2.t("incorrectCmd", CLocal),
|
|
332
|
+
TranslationLoader2.t("misuseShell", CLocal),
|
|
314
333
|
status11.SERVICE_UNAVAILABLE
|
|
315
334
|
);
|
|
316
335
|
this.logger.error(
|
|
317
336
|
this.stackTrace.message,
|
|
318
|
-
|
|
319
|
-
|
|
337
|
+
TranslationLoader2.t("exited", CLocal),
|
|
338
|
+
TranslationLoader2.t("incorrectCmd", CLocal),
|
|
320
339
|
this.stackTrace.stack,
|
|
321
340
|
status11.SERVICE_UNAVAILABLE
|
|
322
341
|
);
|
|
323
342
|
break;
|
|
324
343
|
case 126:
|
|
325
344
|
this.stackTrace = this.traceError(
|
|
326
|
-
|
|
327
|
-
|
|
345
|
+
TranslationLoader2.t("incorrectCmd", CLocal),
|
|
346
|
+
TranslationLoader2.t("cmdNotExecutable", CLocal),
|
|
328
347
|
status11.SERVICE_UNAVAILABLE
|
|
329
348
|
);
|
|
330
349
|
this.logger.error(
|
|
331
350
|
this.stackTrace.message,
|
|
332
|
-
|
|
351
|
+
TranslationLoader2.t("exited", CLocal),
|
|
333
352
|
this.stackTrace.name,
|
|
334
353
|
this.stackTrace.stack,
|
|
335
354
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -337,13 +356,13 @@ var ServerListenEventError = class {
|
|
|
337
356
|
break;
|
|
338
357
|
case 127:
|
|
339
358
|
this.stackTrace = this.traceError(
|
|
340
|
-
|
|
341
|
-
|
|
359
|
+
TranslationLoader2.t("cmdNotFound", CLocal),
|
|
360
|
+
TranslationLoader2.t("cmdNotFoundInSystemPath", CLocal),
|
|
342
361
|
status11.SERVICE_UNAVAILABLE
|
|
343
362
|
);
|
|
344
363
|
this.logger.error(
|
|
345
364
|
this.stackTrace.message,
|
|
346
|
-
|
|
365
|
+
TranslationLoader2.t("exited", CLocal),
|
|
347
366
|
this.stackTrace.name,
|
|
348
367
|
this.stackTrace.stack,
|
|
349
368
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -351,13 +370,13 @@ var ServerListenEventError = class {
|
|
|
351
370
|
break;
|
|
352
371
|
case 128:
|
|
353
372
|
this.stackTrace = this.traceError(
|
|
354
|
-
|
|
355
|
-
|
|
373
|
+
TranslationLoader2.t("cmdNotFoundInSystemPath", CLocal),
|
|
374
|
+
TranslationLoader2.t("argInvalid", CLocal),
|
|
356
375
|
status11.SERVICE_UNAVAILABLE
|
|
357
376
|
);
|
|
358
377
|
this.logger.error(
|
|
359
378
|
this.stackTrace.message,
|
|
360
|
-
|
|
379
|
+
TranslationLoader2.t("exited", CLocal),
|
|
361
380
|
this.stackTrace.name,
|
|
362
381
|
this.stackTrace.stack,
|
|
363
382
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -365,13 +384,13 @@ var ServerListenEventError = class {
|
|
|
365
384
|
break;
|
|
366
385
|
case 130:
|
|
367
386
|
this.stackTrace = this.traceError(
|
|
368
|
-
|
|
369
|
-
|
|
387
|
+
TranslationLoader2.t("scriptEndedManuallyByCtrlC", CLocal),
|
|
388
|
+
TranslationLoader2.t("scriptEnded", CLocal),
|
|
370
389
|
status11.SERVICE_UNAVAILABLE
|
|
371
390
|
);
|
|
372
391
|
this.logger.error(
|
|
373
392
|
this.stackTrace.message,
|
|
374
|
-
|
|
393
|
+
TranslationLoader2.t("exited", CLocal),
|
|
375
394
|
this.stackTrace.name,
|
|
376
395
|
this.stackTrace.stack,
|
|
377
396
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -379,13 +398,13 @@ var ServerListenEventError = class {
|
|
|
379
398
|
break;
|
|
380
399
|
case 137:
|
|
381
400
|
this.stackTrace = this.traceError(
|
|
382
|
-
|
|
401
|
+
TranslationLoader2.t("processEndedBySIGKILL", CLocal),
|
|
383
402
|
"SIGKILL",
|
|
384
403
|
status11.SERVICE_UNAVAILABLE
|
|
385
404
|
);
|
|
386
405
|
this.logger.error(
|
|
387
406
|
this.stackTrace.message,
|
|
388
|
-
|
|
407
|
+
TranslationLoader2.t("exited", CLocal),
|
|
389
408
|
this.stackTrace.name,
|
|
390
409
|
this.stackTrace.stack,
|
|
391
410
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -393,13 +412,13 @@ var ServerListenEventError = class {
|
|
|
393
412
|
break;
|
|
394
413
|
case 139:
|
|
395
414
|
this.stackTrace = this.traceError(
|
|
396
|
-
|
|
397
|
-
|
|
415
|
+
TranslationLoader2.t("accessProcessIllegally", CLocal),
|
|
416
|
+
TranslationLoader2.t("defaultSegment", CLocal),
|
|
398
417
|
status11.SERVICE_UNAVAILABLE
|
|
399
418
|
);
|
|
400
419
|
this.logger.error(
|
|
401
420
|
this.stackTrace.message,
|
|
402
|
-
|
|
421
|
+
TranslationLoader2.t("exited", CLocal),
|
|
403
422
|
this.stackTrace.name,
|
|
404
423
|
this.stackTrace.stack,
|
|
405
424
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -407,13 +426,13 @@ var ServerListenEventError = class {
|
|
|
407
426
|
break;
|
|
408
427
|
case 143:
|
|
409
428
|
this.stackTrace = this.traceError(
|
|
410
|
-
|
|
411
|
-
|
|
429
|
+
TranslationLoader2.t("processReceivedSigtermSignal", CLocal),
|
|
430
|
+
TranslationLoader2.t("processReceived", CLocal),
|
|
412
431
|
status11.SERVICE_UNAVAILABLE
|
|
413
432
|
);
|
|
414
433
|
this.logger.error(
|
|
415
434
|
this.stackTrace.message,
|
|
416
|
-
|
|
435
|
+
TranslationLoader2.t("exited", CLocal),
|
|
417
436
|
this.stackTrace.name,
|
|
418
437
|
this.stackTrace.stack,
|
|
419
438
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -421,13 +440,13 @@ var ServerListenEventError = class {
|
|
|
421
440
|
break;
|
|
422
441
|
case 255:
|
|
423
442
|
this.stackTrace = this.traceError(
|
|
424
|
-
|
|
425
|
-
|
|
443
|
+
TranslationLoader2.t("exitCode", CLocal),
|
|
444
|
+
TranslationLoader2.t("outRange", CLocal),
|
|
426
445
|
status11.SERVICE_UNAVAILABLE
|
|
427
446
|
);
|
|
428
447
|
this.logger.error(
|
|
429
448
|
this.stackTrace.message,
|
|
430
|
-
|
|
449
|
+
TranslationLoader2.t("exited", CLocal),
|
|
431
450
|
this.stackTrace.name,
|
|
432
451
|
this.stackTrace.stack,
|
|
433
452
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -435,13 +454,13 @@ var ServerListenEventError = class {
|
|
|
435
454
|
break;
|
|
436
455
|
default:
|
|
437
456
|
this.stackTrace = this.traceError(
|
|
438
|
-
|
|
439
|
-
|
|
457
|
+
TranslationLoader2.t("errorOccurring", CLocal),
|
|
458
|
+
TranslationLoader2.t("errors", CLocal),
|
|
440
459
|
status11.SERVICE_UNAVAILABLE
|
|
441
460
|
);
|
|
442
461
|
this.logger.error(
|
|
443
462
|
this.stackTrace.message,
|
|
444
|
-
|
|
463
|
+
TranslationLoader2.t("exited", CLocal),
|
|
445
464
|
this.stackTrace.name,
|
|
446
465
|
this.stackTrace.stack,
|
|
447
466
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -456,8 +475,8 @@ var ServerListenEventError = class {
|
|
|
456
475
|
static promiseRejectionHandled(promise) {
|
|
457
476
|
try {
|
|
458
477
|
this.stackTrace = this.traceError(
|
|
459
|
-
|
|
460
|
-
|
|
478
|
+
TranslationLoader2.t("promise", CLocal, { promise }),
|
|
479
|
+
TranslationLoader2.t("rejectionPromise", CLocal, { promise }),
|
|
461
480
|
status11.SERVICE_UNAVAILABLE
|
|
462
481
|
);
|
|
463
482
|
this.logger.error(
|
|
@@ -479,8 +498,8 @@ var ServerListenEventError = class {
|
|
|
479
498
|
console.log("");
|
|
480
499
|
} else {
|
|
481
500
|
this.stackTrace = this.traceError(
|
|
482
|
-
|
|
483
|
-
|
|
501
|
+
TranslationLoader2.t(error.message),
|
|
502
|
+
TranslationLoader2.t("uncaughtExceptionHandled", CLocal),
|
|
484
503
|
status11.SERVICE_UNAVAILABLE
|
|
485
504
|
);
|
|
486
505
|
this.logger.error(
|
|
@@ -508,8 +527,8 @@ var ServerListenEventError = class {
|
|
|
508
527
|
*/
|
|
509
528
|
static unhandledRejection(reason, promise) {
|
|
510
529
|
this.stackTrace = this.traceError(
|
|
511
|
-
|
|
512
|
-
|
|
530
|
+
TranslationLoader2.t("unhandledRejectionAtPromise", CLocal, { promise, reason }),
|
|
531
|
+
TranslationLoader2.t("unhandledRejection", CLocal, { promise, reason }),
|
|
513
532
|
status11.SERVICE_UNAVAILABLE
|
|
514
533
|
);
|
|
515
534
|
this.logger.error(
|
|
@@ -526,13 +545,13 @@ var ServerListenEventError = class {
|
|
|
526
545
|
*/
|
|
527
546
|
static warning(warning) {
|
|
528
547
|
this.stackTrace = this.traceError(
|
|
529
|
-
|
|
548
|
+
TranslationLoader2.t(warning.message, CLocal),
|
|
530
549
|
"warning",
|
|
531
550
|
status11.SERVICE_UNAVAILABLE
|
|
532
551
|
);
|
|
533
552
|
this.logger.error(
|
|
534
553
|
this.stackTrace.message,
|
|
535
|
-
|
|
554
|
+
TranslationLoader2.t("warning", CLocal, { warning }),
|
|
536
555
|
this.stackTrace.name,
|
|
537
556
|
this.stackTrace.stack,
|
|
538
557
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -544,8 +563,8 @@ var ServerListenEventError = class {
|
|
|
544
563
|
*/
|
|
545
564
|
static message(message) {
|
|
546
565
|
this.stackTrace = this.traceError(
|
|
547
|
-
|
|
548
|
-
|
|
566
|
+
TranslationLoader2.t("processGotMsg", CLocal, { message }),
|
|
567
|
+
TranslationLoader2.t("msgException", CLocal, { message }),
|
|
549
568
|
status11.SERVICE_UNAVAILABLE
|
|
550
569
|
);
|
|
551
570
|
this.logger.error(
|
|
@@ -564,8 +583,8 @@ var ServerListenEventError = class {
|
|
|
564
583
|
*/
|
|
565
584
|
static multipleResolves(type, promise, reason) {
|
|
566
585
|
this.stackTrace = this.traceError(
|
|
567
|
-
|
|
568
|
-
|
|
586
|
+
TranslationLoader2.t("promiseReason", CLocal, { promise, reason }),
|
|
587
|
+
TranslationLoader2.t("multipleResolvesDetected", CLocal, { type, promise, reason }),
|
|
569
588
|
status11.SERVICE_UNAVAILABLE
|
|
570
589
|
);
|
|
571
590
|
this.logger.error(
|
|
@@ -580,7 +599,7 @@ var ServerListenEventError = class {
|
|
|
580
599
|
*
|
|
581
600
|
*/
|
|
582
601
|
static processInterrupted() {
|
|
583
|
-
this.logger.success(
|
|
602
|
+
this.logger.success(TranslationLoader2.t("okSuccess", CLocal), TranslationLoader2.t("serverWebStopped", CLocal));
|
|
584
603
|
process.exit(0);
|
|
585
604
|
}
|
|
586
605
|
/**
|
|
@@ -589,7 +608,7 @@ var ServerListenEventError = class {
|
|
|
589
608
|
*/
|
|
590
609
|
static sigtermSignalReceived(signal) {
|
|
591
610
|
this.stackTrace = this.traceError(
|
|
592
|
-
|
|
611
|
+
TranslationLoader2.t("processPIDReceivedSignal", CLocal, { signal: signal.toString() }),
|
|
593
612
|
"SIGTERM",
|
|
594
613
|
status11.NOT_ACCEPTABLE
|
|
595
614
|
);
|
|
@@ -606,15 +625,15 @@ var ServerListenEventError = class {
|
|
|
606
625
|
*
|
|
607
626
|
*/
|
|
608
627
|
static serverClosing() {
|
|
609
|
-
console.log(`${colors.bgCyanBright(` ${colors.bold(`${colors.white(` INFO `)}`)}`)} ${
|
|
610
|
-
console.log(` ${
|
|
628
|
+
console.log(`${colors.bgCyanBright(` ${colors.bold(`${colors.white(` INFO `)}`)}`)} ${TranslationLoader2.t("allProcessStopped", CLocal)}`);
|
|
629
|
+
console.log(` ${TranslationLoader2.t("serverClosed", CLocal)}`);
|
|
611
630
|
process.exit();
|
|
612
631
|
}
|
|
613
632
|
/**
|
|
614
633
|
*
|
|
615
634
|
*/
|
|
616
635
|
static dropNewConnection() {
|
|
617
|
-
console.log(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(` ${
|
|
636
|
+
console.log(`${colors.cyan(`\u24D8`)} ${colors.bgCyan(` ${colors.bold(`${colors.white(` ${TranslationLoader2.t("serverMaxCon", CLocal)} `)}`)} `)} ${dateTimeFormatted} | ${colors.bgCyan(`${colors.white(` Info `)}`)} ${TranslationLoader2.t("serverDroppedCon", CLocal)}`);
|
|
618
637
|
}
|
|
619
638
|
/**
|
|
620
639
|
*
|
|
@@ -628,24 +647,24 @@ var ServerListenEventError = class {
|
|
|
628
647
|
if (err) {
|
|
629
648
|
errorEmitter.emit(CEventNameError.error, err);
|
|
630
649
|
if (typeof res.status === "function") {
|
|
631
|
-
res.status(500).send(
|
|
650
|
+
res.status(500).send(TranslationLoader2.t("internalServerError", CLocal, { err }));
|
|
632
651
|
} else {
|
|
633
652
|
this.logger.error(
|
|
634
|
-
|
|
653
|
+
TranslationLoader2.t("resStatusNotFunc", CLocal, { err }),
|
|
635
654
|
"response status",
|
|
636
|
-
|
|
655
|
+
TranslationLoader2.t("respndNotFunc", CLocal, { err }),
|
|
637
656
|
err.stack,
|
|
638
657
|
status11.NOT_ACCEPTABLE
|
|
639
658
|
);
|
|
640
659
|
}
|
|
641
660
|
this.stackTrace = this.traceError(
|
|
642
661
|
err.message,
|
|
643
|
-
|
|
662
|
+
TranslationLoader2.t("expressError", CLocal, { err }),
|
|
644
663
|
status11.NOT_ACCEPTABLE
|
|
645
664
|
);
|
|
646
665
|
this.logger.error(
|
|
647
666
|
this.stackTrace.message,
|
|
648
|
-
|
|
667
|
+
TranslationLoader2.t("expressErrorHandlingMiddleware", CLocal, { err }),
|
|
649
668
|
this.stackTrace.name,
|
|
650
669
|
this.stackTrace.stack,
|
|
651
670
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -659,14 +678,6 @@ var ServerListenEventError = class {
|
|
|
659
678
|
}
|
|
660
679
|
};
|
|
661
680
|
ServerListenEventError.logger = new LoggerCore();
|
|
662
|
-
|
|
663
|
-
// src/core/config/loaders/translateLanguage.loader.ts
|
|
664
|
-
import path from "path";
|
|
665
|
-
import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
666
|
-
import { getEnvVariable as getEnvVariable2 } from "opticore-env-access";
|
|
667
|
-
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
668
|
-
TranslationLoader2.loadTranslations(path.join("src", "shared", "translations"), getEnvVariable2.defaultLocal);
|
|
669
|
-
};
|
|
670
681
|
export {
|
|
671
682
|
CErrorName,
|
|
672
683
|
CEvent,
|
|
@@ -682,6 +693,5 @@ export {
|
|
|
682
693
|
StackTraceSyntaxError,
|
|
683
694
|
StackTraceSystemError,
|
|
684
695
|
StackTraceTypeError,
|
|
685
|
-
StackTraceURIError
|
|
686
|
-
translateCatchExceptionErrorLanguageLoader
|
|
696
|
+
StackTraceURIError
|
|
687
697
|
};
|
package/example/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {CLocal, TranslationLoader} from "opticore-translator";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import {ServerListenEventError} from "../src";
|
|
4
|
+
import process from "process";
|
|
5
|
+
|
|
6
|
+
console.log(TranslationLoader.t("rejectionPromise", 'en', { promise: "wd digital" }));
|
|
7
|
+
//console.log("__init is : ", ServerListenEventError.__init());
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
|
|
11
|
+
// Convertir l'URL du fichier en chemin de fichier
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
console.log("__filename is : ", __filename);
|
|
14
|
+
|
|
15
|
+
// Obtenir le répertoire du fichier
|
|
16
|
+
(() => {
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
const server = ServerListenEventError.__init();
|
|
19
|
+
server.hostPortUndefined();
|
|
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.8",
|
|
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.3",
|
|
32
32
|
"tsx": "^4.19.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|