opticore-catch-exception-error 1.0.1 → 1.0.2

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 CHANGED
@@ -331,7 +331,10 @@ var ServerListenEventError = class {
331
331
  static exited(code) {
332
332
  switch (code) {
333
333
  case 0:
334
- this.logger.success(import_opticore_translator.TranslationLoader.t("completed", import_opticore_translator.CLocal), import_opticore_translator.TranslationLoader.t("finishingProcessWell", import_opticore_translator.CLocal));
334
+ this.logger.success(
335
+ import_opticore_translator.TranslationLoader.t("completed", import_opticore_translator.CLocal, {}),
336
+ import_opticore_translator.TranslationLoader.t("finishingProcessWell", import_opticore_translator.CLocal, { code })
337
+ );
335
338
  console.log("");
336
339
  const paddingLength = 35;
337
340
  const msg0 = " ".padEnd(paddingLength, " ");
@@ -500,18 +503,21 @@ var ServerListenEventError = class {
500
503
  * @param promise
501
504
  */
502
505
  static promiseRejectionHandled(promise) {
503
- this.stackTrace = this.traceError(
504
- import_opticore_translator.TranslationLoader.t("promise", import_opticore_translator.CLocal, { promise }),
505
- import_opticore_translator.TranslationLoader.t("rejectionPromise", import_opticore_translator.CLocal),
506
- import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
507
- );
508
- this.logger.error(
509
- this.stackTrace.message,
510
- "PromiseRejectionHandled",
511
- this.stackTrace.name,
512
- this.stackTrace.stack,
513
- import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
514
- );
506
+ try {
507
+ this.stackTrace = this.traceError(
508
+ import_opticore_translator.TranslationLoader.t("promise", import_opticore_translator.CLocal, { promise }),
509
+ import_opticore_translator.TranslationLoader.t("rejectionPromise", import_opticore_translator.CLocal),
510
+ import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
511
+ );
512
+ this.logger.error(
513
+ this.stackTrace.message,
514
+ "PromiseRejectionHandled",
515
+ this.stackTrace.name,
516
+ this.stackTrace.stack,
517
+ import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
518
+ );
519
+ } catch (err) {
520
+ }
515
521
  }
516
522
  /**
517
523
  *
@@ -551,7 +557,7 @@ var ServerListenEventError = class {
551
557
  */
552
558
  static unhandledRejection(reason, promise) {
553
559
  this.stackTrace = this.traceError(
554
- import_opticore_translator.TranslationLoader.t("unhandledRejectionAtPromise", import_opticore_translator.CLocal),
560
+ import_opticore_translator.TranslationLoader.t("unhandledRejectionAtPromise", import_opticore_translator.CLocal, { promise, reason }),
555
561
  import_opticore_translator.TranslationLoader.t("unhandledRejection", import_opticore_translator.CLocal),
556
562
  import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
557
563
  );
@@ -575,7 +581,7 @@ var ServerListenEventError = class {
575
581
  );
576
582
  this.logger.error(
577
583
  this.stackTrace.message,
578
- import_opticore_translator.TranslationLoader.t("Warning", import_opticore_translator.CLocal),
584
+ import_opticore_translator.TranslationLoader.t("warning", import_opticore_translator.CLocal),
579
585
  this.stackTrace.name,
580
586
  this.stackTrace.stack,
581
587
  import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
@@ -671,21 +677,24 @@ var ServerListenEventError = class {
671
677
  if (err) {
672
678
  errorEmitter.emit(CEventNameError.error, err);
673
679
  if (typeof res.status === "function") {
674
- res.status(500).send(import_opticore_translator.TranslationLoader.t("internalServerError", import_opticore_translator.CLocal));
680
+ res.status(500).send(import_opticore_translator.TranslationLoader.t("internalServerError", import_opticore_translator.CLocal, { err }));
675
681
  } else {
676
- console.error("res.status is not a function");
677
682
  this.logger.error(
678
- import_opticore_translator.TranslationLoader.t("resStatusNotFunc", import_opticore_translator.CLocal),
683
+ import_opticore_translator.TranslationLoader.t("resStatusNotFunc", import_opticore_translator.CLocal, { err }),
679
684
  "response status",
680
- import_opticore_translator.TranslationLoader.t("respndNotFunc", import_opticore_translator.CLocal),
685
+ import_opticore_translator.TranslationLoader.t("respndNotFunc", import_opticore_translator.CLocal, { err }),
681
686
  err.stack,
682
687
  import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
683
688
  );
684
689
  }
685
- this.stackTrace = this.traceError(err.message, import_opticore_translator.TranslationLoader.t("expressError", import_opticore_translator.CLocal), import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE);
690
+ this.stackTrace = this.traceError(
691
+ err.message,
692
+ import_opticore_translator.TranslationLoader.t("expressError", import_opticore_translator.CLocal, { err }),
693
+ import_opticore_http_response11.HttpStatusCode.NOT_ACCEPTABLE
694
+ );
686
695
  this.logger.error(
687
696
  this.stackTrace.message,
688
- import_opticore_translator.TranslationLoader.t("expressErrorHandlingMiddleware", import_opticore_translator.CLocal),
697
+ import_opticore_translator.TranslationLoader.t("expressErrorHandlingMiddleware", import_opticore_translator.CLocal, { err }),
689
698
  this.stackTrace.name,
690
699
  this.stackTrace.stack,
691
700
  import_opticore_http_response11.HttpStatusCode.SERVICE_UNAVAILABLE
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;
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;
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(TranslationLoader.t("completed", CLocal), TranslationLoader.t("finishingProcessWell", CLocal));
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
- this.stackTrace = this.traceError(
454
- TranslationLoader.t("promise", CLocal, { promise }),
455
- TranslationLoader.t("rejectionPromise", CLocal),
456
- status11.SERVICE_UNAVAILABLE
457
- );
458
- this.logger.error(
459
- this.stackTrace.message,
460
- "PromiseRejectionHandled",
461
- this.stackTrace.name,
462
- this.stackTrace.stack,
463
- status11.SERVICE_UNAVAILABLE
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("Warning", CLocal),
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(err.message, TranslationLoader.t("expressError", CLocal), status11.NOT_ACCEPTABLE);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticore-catch-exception-error",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "opticore catch exception error",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",