opticore-catch-exception-error 1.0.1 → 1.0.3
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 +43 -23
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +41 -22
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,8 @@ __export(index_exports, {
|
|
|
44
44
|
StackTraceSyntaxError: () => StackTraceSyntaxError,
|
|
45
45
|
StackTraceSystemError: () => StackTraceSystemError,
|
|
46
46
|
StackTraceTypeError: () => StackTraceTypeError,
|
|
47
|
-
StackTraceURIError: () => StackTraceURIError
|
|
47
|
+
StackTraceURIError: () => StackTraceURIError,
|
|
48
|
+
translateCatchExceptionErrorLanguageLoader: () => translateCatchExceptionErrorLanguageLoader
|
|
48
49
|
});
|
|
49
50
|
module.exports = __toCommonJS(index_exports);
|
|
50
51
|
|
|
@@ -331,7 +332,10 @@ var ServerListenEventError = class {
|
|
|
331
332
|
static exited(code) {
|
|
332
333
|
switch (code) {
|
|
333
334
|
case 0:
|
|
334
|
-
this.logger.success(
|
|
335
|
+
this.logger.success(
|
|
336
|
+
import_opticore_translator.TranslationLoader.t("completed", import_opticore_translator.CLocal, {}),
|
|
337
|
+
import_opticore_translator.TranslationLoader.t("finishingProcessWell", import_opticore_translator.CLocal, { code })
|
|
338
|
+
);
|
|
335
339
|
console.log("");
|
|
336
340
|
const paddingLength = 35;
|
|
337
341
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
@@ -500,18 +504,21 @@ var ServerListenEventError = class {
|
|
|
500
504
|
* @param promise
|
|
501
505
|
*/
|
|
502
506
|
static promiseRejectionHandled(promise) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
this.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
507
|
+
try {
|
|
508
|
+
this.stackTrace = this.traceError(
|
|
509
|
+
import_opticore_translator.TranslationLoader.t("promise", import_opticore_translator.CLocal, { promise }),
|
|
510
|
+
import_opticore_translator.TranslationLoader.t("rejectionPromise", import_opticore_translator.CLocal),
|
|
511
|
+
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
512
|
+
);
|
|
513
|
+
this.logger.error(
|
|
514
|
+
this.stackTrace.message,
|
|
515
|
+
"PromiseRejectionHandled",
|
|
516
|
+
this.stackTrace.name,
|
|
517
|
+
this.stackTrace.stack,
|
|
518
|
+
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
519
|
+
);
|
|
520
|
+
} catch (err) {
|
|
521
|
+
}
|
|
515
522
|
}
|
|
516
523
|
/**
|
|
517
524
|
*
|
|
@@ -551,7 +558,7 @@ var ServerListenEventError = class {
|
|
|
551
558
|
*/
|
|
552
559
|
static unhandledRejection(reason, promise) {
|
|
553
560
|
this.stackTrace = this.traceError(
|
|
554
|
-
import_opticore_translator.TranslationLoader.t("unhandledRejectionAtPromise", import_opticore_translator.CLocal),
|
|
561
|
+
import_opticore_translator.TranslationLoader.t("unhandledRejectionAtPromise", import_opticore_translator.CLocal, { promise, reason }),
|
|
555
562
|
import_opticore_translator.TranslationLoader.t("unhandledRejection", import_opticore_translator.CLocal),
|
|
556
563
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
557
564
|
);
|
|
@@ -575,7 +582,7 @@ var ServerListenEventError = class {
|
|
|
575
582
|
);
|
|
576
583
|
this.logger.error(
|
|
577
584
|
this.stackTrace.message,
|
|
578
|
-
import_opticore_translator.TranslationLoader.t("
|
|
585
|
+
import_opticore_translator.TranslationLoader.t("warning", import_opticore_translator.CLocal),
|
|
579
586
|
this.stackTrace.name,
|
|
580
587
|
this.stackTrace.stack,
|
|
581
588
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -671,21 +678,24 @@ var ServerListenEventError = class {
|
|
|
671
678
|
if (err) {
|
|
672
679
|
errorEmitter.emit(CEventNameError.error, err);
|
|
673
680
|
if (typeof res.status === "function") {
|
|
674
|
-
res.status(500).send(import_opticore_translator.TranslationLoader.t("internalServerError", import_opticore_translator.CLocal));
|
|
681
|
+
res.status(500).send(import_opticore_translator.TranslationLoader.t("internalServerError", import_opticore_translator.CLocal, { err }));
|
|
675
682
|
} else {
|
|
676
|
-
console.error("res.status is not a function");
|
|
677
683
|
this.logger.error(
|
|
678
|
-
import_opticore_translator.TranslationLoader.t("resStatusNotFunc", import_opticore_translator.CLocal),
|
|
684
|
+
import_opticore_translator.TranslationLoader.t("resStatusNotFunc", import_opticore_translator.CLocal, { err }),
|
|
679
685
|
"response status",
|
|
680
|
-
import_opticore_translator.TranslationLoader.t("respndNotFunc", import_opticore_translator.CLocal),
|
|
686
|
+
import_opticore_translator.TranslationLoader.t("respndNotFunc", import_opticore_translator.CLocal, { err }),
|
|
681
687
|
err.stack,
|
|
682
688
|
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
683
689
|
);
|
|
684
690
|
}
|
|
685
|
-
this.stackTrace = this.traceError(
|
|
691
|
+
this.stackTrace = this.traceError(
|
|
692
|
+
err.message,
|
|
693
|
+
import_opticore_translator.TranslationLoader.t("expressError", import_opticore_translator.CLocal, { err }),
|
|
694
|
+
import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
|
|
695
|
+
);
|
|
686
696
|
this.logger.error(
|
|
687
697
|
this.stackTrace.message,
|
|
688
|
-
import_opticore_translator.TranslationLoader.t("expressErrorHandlingMiddleware", import_opticore_translator.CLocal),
|
|
698
|
+
import_opticore_translator.TranslationLoader.t("expressErrorHandlingMiddleware", import_opticore_translator.CLocal, { err }),
|
|
689
699
|
this.stackTrace.name,
|
|
690
700
|
this.stackTrace.stack,
|
|
691
701
|
import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
|
|
@@ -699,6 +709,15 @@ var ServerListenEventError = class {
|
|
|
699
709
|
}
|
|
700
710
|
};
|
|
701
711
|
ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
|
|
712
|
+
|
|
713
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
714
|
+
var import_path = __toESM(require("path"), 1);
|
|
715
|
+
var import_opticore_translator2 = require("opticore-translator");
|
|
716
|
+
var import_opticore_env_access = require("opticore-env-access");
|
|
717
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
718
|
+
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
719
|
+
import_opticore_translator2.TranslationLoader.loadTranslations(import_path.default.join(import_node_process.default.cwd(), "src", "utils", "translations"), import_opticore_env_access.getEnvVariable.defaultLocal);
|
|
720
|
+
};
|
|
702
721
|
// Annotate the CommonJS export names for ESM import in node:
|
|
703
722
|
0 && (module.exports = {
|
|
704
723
|
CErrorName,
|
|
@@ -715,5 +734,6 @@ ServerListenEventError.logger = new import_opticore_logger.LoggerCore();
|
|
|
715
734
|
StackTraceSyntaxError,
|
|
716
735
|
StackTraceSystemError,
|
|
717
736
|
StackTraceTypeError,
|
|
718
|
-
StackTraceURIError
|
|
737
|
+
StackTraceURIError,
|
|
738
|
+
translateCatchExceptionErrorLanguageLoader
|
|
719
739
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpStatusCode } from 'opticore-http-response';
|
|
2
|
-
import { Request, Response, NextFunction } from 'opticore-express';
|
|
3
2
|
import EventEmitter from 'node:events';
|
|
3
|
+
import { Request, Response, NextFunction } from 'opticore-express';
|
|
4
4
|
|
|
5
5
|
declare const CErrorName: {
|
|
6
6
|
evalError: string;
|
|
@@ -233,4 +233,6 @@ declare class ServerListenEventError {
|
|
|
233
233
|
private static traceError;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
declare const translateCatchExceptionErrorLanguageLoader: () => void;
|
|
237
|
+
|
|
238
|
+
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError, translateCatchExceptionErrorLanguageLoader };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpStatusCode } from 'opticore-http-response';
|
|
2
|
-
import { Request, Response, NextFunction } from 'opticore-express';
|
|
3
2
|
import EventEmitter from 'node:events';
|
|
3
|
+
import { Request, Response, NextFunction } from 'opticore-express';
|
|
4
4
|
|
|
5
5
|
declare const CErrorName: {
|
|
6
6
|
evalError: string;
|
|
@@ -233,4 +233,6 @@ declare class ServerListenEventError {
|
|
|
233
233
|
private static traceError;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
declare const translateCatchExceptionErrorLanguageLoader: () => void;
|
|
237
|
+
|
|
238
|
+
export { CErrorName, CEvent, CEventNameError, ServerListenEventError, StackTraceAssertionError, StackTraceError, StackTraceEvalError, StackTraceGeneralError, StackTraceOpenSSLError, StackTraceRangeError, StackTraceReferenceError, StackTraceSyntaxError, StackTraceSystemError, StackTraceTypeError, StackTraceURIError, translateCatchExceptionErrorLanguageLoader };
|
package/dist/index.js
CHANGED
|
@@ -281,7 +281,10 @@ var ServerListenEventError = class {
|
|
|
281
281
|
static exited(code) {
|
|
282
282
|
switch (code) {
|
|
283
283
|
case 0:
|
|
284
|
-
this.logger.success(
|
|
284
|
+
this.logger.success(
|
|
285
|
+
TranslationLoader.t("completed", CLocal, {}),
|
|
286
|
+
TranslationLoader.t("finishingProcessWell", CLocal, { code })
|
|
287
|
+
);
|
|
285
288
|
console.log("");
|
|
286
289
|
const paddingLength = 35;
|
|
287
290
|
const msg0 = " ".padEnd(paddingLength, " ");
|
|
@@ -450,18 +453,21 @@ var ServerListenEventError = class {
|
|
|
450
453
|
* @param promise
|
|
451
454
|
*/
|
|
452
455
|
static promiseRejectionHandled(promise) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
this.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
456
|
+
try {
|
|
457
|
+
this.stackTrace = this.traceError(
|
|
458
|
+
TranslationLoader.t("promise", CLocal, { promise }),
|
|
459
|
+
TranslationLoader.t("rejectionPromise", CLocal),
|
|
460
|
+
status11.SERVICE_UNAVAILABLE
|
|
461
|
+
);
|
|
462
|
+
this.logger.error(
|
|
463
|
+
this.stackTrace.message,
|
|
464
|
+
"PromiseRejectionHandled",
|
|
465
|
+
this.stackTrace.name,
|
|
466
|
+
this.stackTrace.stack,
|
|
467
|
+
status11.SERVICE_UNAVAILABLE
|
|
468
|
+
);
|
|
469
|
+
} catch (err) {
|
|
470
|
+
}
|
|
465
471
|
}
|
|
466
472
|
/**
|
|
467
473
|
*
|
|
@@ -501,7 +507,7 @@ var ServerListenEventError = class {
|
|
|
501
507
|
*/
|
|
502
508
|
static unhandledRejection(reason, promise) {
|
|
503
509
|
this.stackTrace = this.traceError(
|
|
504
|
-
TranslationLoader.t("unhandledRejectionAtPromise", CLocal),
|
|
510
|
+
TranslationLoader.t("unhandledRejectionAtPromise", CLocal, { promise, reason }),
|
|
505
511
|
TranslationLoader.t("unhandledRejection", CLocal),
|
|
506
512
|
status11.SERVICE_UNAVAILABLE
|
|
507
513
|
);
|
|
@@ -525,7 +531,7 @@ var ServerListenEventError = class {
|
|
|
525
531
|
);
|
|
526
532
|
this.logger.error(
|
|
527
533
|
this.stackTrace.message,
|
|
528
|
-
TranslationLoader.t("
|
|
534
|
+
TranslationLoader.t("warning", CLocal),
|
|
529
535
|
this.stackTrace.name,
|
|
530
536
|
this.stackTrace.stack,
|
|
531
537
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -621,21 +627,24 @@ var ServerListenEventError = class {
|
|
|
621
627
|
if (err) {
|
|
622
628
|
errorEmitter.emit(CEventNameError.error, err);
|
|
623
629
|
if (typeof res.status === "function") {
|
|
624
|
-
res.status(500).send(TranslationLoader.t("internalServerError", CLocal));
|
|
630
|
+
res.status(500).send(TranslationLoader.t("internalServerError", CLocal, { err }));
|
|
625
631
|
} else {
|
|
626
|
-
console.error("res.status is not a function");
|
|
627
632
|
this.logger.error(
|
|
628
|
-
TranslationLoader.t("resStatusNotFunc", CLocal),
|
|
633
|
+
TranslationLoader.t("resStatusNotFunc", CLocal, { err }),
|
|
629
634
|
"response status",
|
|
630
|
-
TranslationLoader.t("respndNotFunc", CLocal),
|
|
635
|
+
TranslationLoader.t("respndNotFunc", CLocal, { err }),
|
|
631
636
|
err.stack,
|
|
632
637
|
status11.NOT_ACCEPTABLE
|
|
633
638
|
);
|
|
634
639
|
}
|
|
635
|
-
this.stackTrace = this.traceError(
|
|
640
|
+
this.stackTrace = this.traceError(
|
|
641
|
+
err.message,
|
|
642
|
+
TranslationLoader.t("expressError", CLocal, { err }),
|
|
643
|
+
status11.NOT_ACCEPTABLE
|
|
644
|
+
);
|
|
636
645
|
this.logger.error(
|
|
637
646
|
this.stackTrace.message,
|
|
638
|
-
TranslationLoader.t("expressErrorHandlingMiddleware", CLocal),
|
|
647
|
+
TranslationLoader.t("expressErrorHandlingMiddleware", CLocal, { err }),
|
|
639
648
|
this.stackTrace.name,
|
|
640
649
|
this.stackTrace.stack,
|
|
641
650
|
status11.SERVICE_UNAVAILABLE
|
|
@@ -649,6 +658,15 @@ var ServerListenEventError = class {
|
|
|
649
658
|
}
|
|
650
659
|
};
|
|
651
660
|
ServerListenEventError.logger = new LoggerCore();
|
|
661
|
+
|
|
662
|
+
// src/core/config/loaders/translateLanguage.loader.ts
|
|
663
|
+
import path from "path";
|
|
664
|
+
import { TranslationLoader as TranslationLoader2 } from "opticore-translator";
|
|
665
|
+
import { getEnvVariable } from "opticore-env-access";
|
|
666
|
+
import process2 from "node:process";
|
|
667
|
+
var translateCatchExceptionErrorLanguageLoader = () => {
|
|
668
|
+
TranslationLoader2.loadTranslations(path.join(process2.cwd(), "src", "utils", "translations"), getEnvVariable.defaultLocal);
|
|
669
|
+
};
|
|
652
670
|
export {
|
|
653
671
|
CErrorName,
|
|
654
672
|
CEvent,
|
|
@@ -664,5 +682,6 @@ export {
|
|
|
664
682
|
StackTraceSyntaxError,
|
|
665
683
|
StackTraceSystemError,
|
|
666
684
|
StackTraceTypeError,
|
|
667
|
-
StackTraceURIError
|
|
685
|
+
StackTraceURIError,
|
|
686
|
+
translateCatchExceptionErrorLanguageLoader
|
|
668
687
|
};
|
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.3",
|
|
4
4
|
"description": "opticore catch exception error",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"homepage": "https://github.com/guyzoum77/opticore-catch-exception-error#readme",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"chalk": "^5.4.1",
|
|
29
|
-
"node": "^22.13.5",
|
|
30
29
|
"opticore-express": "^1.0.1",
|
|
31
30
|
"opticore-http-response": "^1.0.3",
|
|
32
|
-
"opticore-translator": "^1.0.1"
|
|
31
|
+
"opticore-translator": "^1.0.1",
|
|
32
|
+
"tsx": "^4.19.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.13.5",
|