@hg-ts/exception 0.1.39 → 0.1.41

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/.eslintcache CHANGED
@@ -1 +1 @@
1
- [{"/Volumes/Work/ts/hg/framework/packages/exception/src/consts.ts":"1","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/aggregate-error.exception.ts":"2","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.aggregate.exception.ts":"3","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.exception.ts":"4","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/error.exception.ts":"5","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/forbidden.exception.ts":"6","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/index.ts":"7","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/not-implemented.exception.ts":"8","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/unknown.exception.ts":"9","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/will-never-happened.exception.ts":"10","/Volumes/Work/ts/hg/framework/packages/exception/src/index.ts":"11","/Volumes/Work/ts/hg/framework/packages/exception/src/tests/serialization.test-suite.ts":"12","/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.aggregate-exception.ts":"13","/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.exception.ts":"14","/Volumes/Work/ts/hg/framework/packages/exception/src/utils/index.ts":"15","/Volumes/Work/ts/hg/framework/packages/exception/src/utils/stack-trace.formatter.ts":"16"},{"size":73,"mtime":1659719206461,"results":"17","hashOfConfig":"18"},{"size":656,"mtime":1631395128717,"results":"19","hashOfConfig":"18"},{"size":1377,"mtime":1660867889450,"results":"20","hashOfConfig":"18"},{"size":3220,"mtime":1664331682837,"results":"21","hashOfConfig":"18"},{"size":375,"mtime":1658005568468,"results":"22","hashOfConfig":"18"},{"size":108,"mtime":1643091718782,"results":"23","hashOfConfig":"18"},{"size":418,"mtime":1643091718779,"results":"24","hashOfConfig":"18"},{"size":169,"mtime":1626299896345,"results":"25","hashOfConfig":"18"},{"size":167,"mtime":1626299896345,"results":"26","hashOfConfig":"18"},{"size":177,"mtime":1626299896345,"results":"27","hashOfConfig":"18"},{"size":53,"mtime":1665300013469,"results":"28","hashOfConfig":"18"},{"size":3373,"mtime":1665300013444,"results":"29","hashOfConfig":"18"},{"size":430,"mtime":1660867792014,"results":"30","hashOfConfig":"18"},{"size":186,"mtime":1657995065457,"results":"31","hashOfConfig":"18"},{"size":41,"mtime":1626299896346,"results":"32","hashOfConfig":"18"},{"size":930,"mtime":1659719246420,"results":"33","hashOfConfig":"18"},{"filePath":"34","messages":"35","suppressedMessages":"36","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"16009u",{"filePath":"37","messages":"38","suppressedMessages":"39","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"40","messages":"41","suppressedMessages":"42","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"43","messages":"44","suppressedMessages":"45","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"46","messages":"47","suppressedMessages":"48","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"49","messages":"50","suppressedMessages":"51","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","suppressedMessages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"55","messages":"56","suppressedMessages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","suppressedMessages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","suppressedMessages":"66","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","suppressedMessages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","suppressedMessages":"72","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","suppressedMessages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","suppressedMessages":"78","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","suppressedMessages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Volumes/Work/ts/hg/framework/packages/exception/src/consts.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/aggregate-error.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.aggregate.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/error.exception.ts",[],["82"],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/forbidden.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/not-implemented.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/unknown.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/will-never-happened.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/tests/serialization.test-suite.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.aggregate-exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/utils/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/utils/stack-trace.formatter.ts",[],[],{"ruleId":"83","severity":2,"message":"84","line":11,"column":7,"nodeType":"85","messageId":"86","endLine":11,"endColumn":16,"suppressions":"87"},"no-undefined","Unexpected use of undefined.","Identifier","unexpectedUndefined",["88"],{"kind":"89","justification":"90"},"directive",""]
1
+ [{"/Volumes/Work/ts/hg/framework/packages/exception/src/consts.ts":"1","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/aggregate-error.exception.ts":"2","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.aggregate.exception.ts":"3","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.exception.ts":"4","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/error.exception.ts":"5","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/forbidden.exception.ts":"6","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/index.ts":"7","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/not-implemented.exception.ts":"8","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/unknown.exception.ts":"9","/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/will-never-happened.exception.ts":"10","/Volumes/Work/ts/hg/framework/packages/exception/src/index.ts":"11","/Volumes/Work/ts/hg/framework/packages/exception/src/tests/serialization.test-suite.ts":"12","/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.aggregate-exception.ts":"13","/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.exception.ts":"14","/Volumes/Work/ts/hg/framework/packages/exception/src/utils/index.ts":"15","/Volumes/Work/ts/hg/framework/packages/exception/src/utils/stack-trace.formatter.ts":"16"},{"size":73,"mtime":1659719206461,"results":"17","hashOfConfig":"18"},{"size":520,"mtime":1720379890541,"results":"19","hashOfConfig":"18"},{"size":1377,"mtime":1720379841735,"results":"20","hashOfConfig":"18"},{"size":3430,"mtime":1720379783614,"results":"21","hashOfConfig":"18"},{"size":375,"mtime":1658005568468,"results":"22","hashOfConfig":"18"},{"size":108,"mtime":1643091718782,"results":"23","hashOfConfig":"18"},{"size":418,"mtime":1643091718779,"results":"24","hashOfConfig":"18"},{"size":169,"mtime":1626299896345,"results":"25","hashOfConfig":"18"},{"size":167,"mtime":1626299896345,"results":"26","hashOfConfig":"18"},{"size":177,"mtime":1626299896345,"results":"27","hashOfConfig":"18"},{"size":53,"mtime":1665300013469,"results":"28","hashOfConfig":"18"},{"size":3373,"mtime":1720379827230,"results":"29","hashOfConfig":"18"},{"size":430,"mtime":1660867792014,"results":"30","hashOfConfig":"18"},{"size":186,"mtime":1657995065457,"results":"31","hashOfConfig":"18"},{"size":41,"mtime":1626299896346,"results":"32","hashOfConfig":"18"},{"size":930,"mtime":1659719246420,"results":"33","hashOfConfig":"18"},{"filePath":"34","messages":"35","suppressedMessages":"36","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"16009u",{"filePath":"37","messages":"38","suppressedMessages":"39","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"40","messages":"41","suppressedMessages":"42","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"43","messages":"44","suppressedMessages":"45","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"46","messages":"47","suppressedMessages":"48","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"49","messages":"50","suppressedMessages":"51","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","suppressedMessages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"55","messages":"56","suppressedMessages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","suppressedMessages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","suppressedMessages":"66","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","suppressedMessages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","suppressedMessages":"72","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","suppressedMessages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","suppressedMessages":"78","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","suppressedMessages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Volumes/Work/ts/hg/framework/packages/exception/src/consts.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/aggregate-error.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.aggregate.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/base.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/error.exception.ts",[],["82"],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/forbidden.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/not-implemented.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/unknown.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/exceptions/will-never-happened.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/tests/serialization.test-suite.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.aggregate-exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/tests/test.exception.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/utils/index.ts",[],[],"/Volumes/Work/ts/hg/framework/packages/exception/src/utils/stack-trace.formatter.ts",[],[],{"ruleId":"83","severity":2,"message":"84","line":11,"column":7,"nodeType":"85","messageId":"86","endLine":11,"endColumn":16,"suppressions":"87"},"no-undefined","Unexpected use of undefined.","Identifier","unexpectedUndefined",["88"],{"kind":"89","justification":"90"},"directive",""]
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-error.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,qBAAa,uBAAwB,SAAQ,sBAAsB;gBAC/C,KAAK,EAAE,cAAc;CAqBxC"}
1
+ {"version":3,"file":"aggregate-error.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,qBAAa,uBAAwB,SAAQ,sBAAsB;gBAC/C,KAAK,EAAE,cAAc;CAiBxC"}
@@ -9,14 +9,10 @@ class AggregateErrorException extends base_aggregate_exception_1.BaseAggregateEx
9
9
  super(errors
10
10
  .map(error => {
11
11
  if (error instanceof AggregateError) {
12
- base_aggregate_exception_1.BaseAggregateException.fromError(error);
12
+ base_aggregate_exception_1.BaseAggregateException.normalize(error);
13
13
  }
14
- if (error instanceof Error) {
15
- return base_exception_1.BaseException.fromError(error);
16
- }
17
- return null;
18
- })
19
- .filter((exception) => exception !== null), error.message);
14
+ return base_exception_1.BaseException.normalize(error);
15
+ }), error.message);
20
16
  this.stack = error.stack;
21
17
  }
22
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-error.exception.js","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AACpE,qDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,iDAAsB;IAClE,YAAmB,KAAqB;QACvC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,KAAK,CACJ,MAAM;aACJ,GAAG,CAAC,KAAK,CAAC,EAAE;YACZ,IAAI,KAAK,YAAY,cAAc,EAAE;gBACpC,iDAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACxC;YACD,IAAI,KAAK,YAAY,KAAK,EAAE;gBAC3B,OAAO,8BAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACtC;YAED,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,SAAS,EAA8B,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,EACvE,KAAK,CAAC,OAAO,CACb,CAAC;QAED,IAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACnC,CAAC;CACD;AAtBD,0DAsBC"}
1
+ {"version":3,"file":"aggregate-error.exception.js","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AACpE,qDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,iDAAsB;IAClE,YAAmB,KAAqB;QACvC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,KAAK,CACJ,MAAM;aACJ,GAAG,CAAC,KAAK,CAAC,EAAE;YACZ,IAAI,KAAK,YAAY,cAAc,EAAE;gBACpC,iDAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACxC;YAED,OAAO,8BAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC,CAAC,EACH,KAAK,CAAC,OAAO,CACb,CAAC;QAED,IAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACnC,CAAC;CACD;AAlBD,0DAkBC"}
@@ -7,7 +7,7 @@ export declare abstract class BaseAggregateException extends BaseException {
7
7
  readonly exceptions: BaseException[];
8
8
  protected constructor(exceptions: BaseException[], message: string, options?: BaseAggregateExceptionOptions);
9
9
  toJSON(): JSONBaseAggregateException;
10
- static fromError(error: AggregateError): BaseAggregateException;
10
+ static normalize(error: AggregateError): BaseAggregateException;
11
11
  protected injectBeforeStack(padCount: number): string[];
12
12
  }
13
13
  //# sourceMappingURL=base.aggregate.exception.d.ts.map
@@ -16,7 +16,7 @@ class BaseAggregateException extends base_exception_1.BaseException {
16
16
  exceptions: this.exceptions.map(exception => exception.toJSON()),
17
17
  };
18
18
  }
19
- static fromError(error) {
19
+ static normalize(error) {
20
20
  return new aggregate_error_exception_1.AggregateErrorException(error);
21
21
  }
22
22
  injectBeforeStack(padCount) {
@@ -27,7 +27,7 @@ export declare abstract class BaseException extends Error {
27
27
  isFromNextTick(): boolean;
28
28
  isFromImmediate(): boolean;
29
29
  isFromTimer(): boolean;
30
- static fromError(error: Error): BaseException;
30
+ static normalize(error: unknown, defaultMessage?: string): BaseException;
31
31
  protected getCtor(): Function;
32
32
  protected getStringifyFirstLine(): string;
33
33
  protected injectBeforeStack(padCount: number): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"base.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/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,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,sBAAsB,GAAG,MAAM;IAIvF,cAAc,IAAI,OAAO;IAMzB,eAAe,IAAI,OAAO;IAM1B,WAAW,IAAI,OAAO;WAMf,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,SAAuB,GAAG,aAAa;IAY7F,SAAS,CAAC,OAAO,IAAI,QAAQ;IAI7B,SAAS,CAAC,qBAAqB,IAAI,MAAM;IAMzC,SAAS,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAQvD,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIhE,OAAO,CAAC,gBAAgB;CAKxB"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseException = exports.PAD_COUNT_PER_DEPTH = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const os = tslib_1.__importStar(require("os"));
5
+ const os_1 = tslib_1.__importDefault(require("os"));
6
6
  const util_1 = require("util");
7
7
  const utils_1 = require("../utils");
8
8
  const error_exception_1 = require("./error.exception");
@@ -51,7 +51,7 @@ class BaseException extends Error {
51
51
  ...this.injectBeforeStack(padCount + exports.PAD_COUNT_PER_DEPTH),
52
52
  ...formattedStack,
53
53
  ];
54
- return errorLines.join(os.EOL);
54
+ return errorLines.join(os_1.default.EOL);
55
55
  }
56
56
  [util_1.inspect.custom](_depth, { stylize }) {
57
57
  return stylize(this.toString(), 'regexp');
@@ -68,8 +68,14 @@ class BaseException extends Error {
68
68
  const lastLine = this.getLastStackLine();
69
69
  return lastLine.includes('Timeout._onTimeout');
70
70
  }
71
- static fromError(error) {
72
- return new error_exception_1.ErrorException(error);
71
+ static normalize(error, defaultMessage = 'Unknown error type') {
72
+ if (error instanceof BaseException) {
73
+ return error;
74
+ }
75
+ if (error instanceof Error) {
76
+ return new error_exception_1.ErrorException(error);
77
+ }
78
+ return new error_exception_1.ErrorException(new Error(defaultMessage, { cause: error }));
73
79
  }
74
80
  getCtor() {
75
81
  return Object.getPrototypeOf(this).constructor;
@@ -1 +1 @@
1
- {"version":3,"file":"base.exception.js","sourceRoot":"","sources":["../../src/exceptions/base.exception.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,+BAGc;AAEd,oCAA+C;AAC/C,uDAAmD;AAetC,QAAA,mBAAmB,GAAG,CAAC,CAAC;AAErC,MAAsB,aAAc,SAAQ,KAAK;IAChC,IAAI,GAAqB,IAAI,CAAC;IACrB,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,KAAK,CAAiB;IACvC,UAAU,GAAgC,IAAI,CAAC;IAEvD,YAAmB,OAAe,EAAE,gBAAkC,EAAE;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,aAAa,CAAC,KAAK,EAAE;YACxB,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;SACjC;QACD,IAAI,aAAa,CAAC,IAAI,EAAE;YACvB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;SAC/B;QAED,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAoB,IAAI;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAEhC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM;QACZ,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE;YAC7B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;YAEnD,IAAI,CAAC,UAAU,GAAG;gBACjB,IAAI;gBACJ,IAAI;gBACJ,OAAO;gBACP,KAAK,EAAE,2BAA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cAAc,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;IAES,OAAO;QAChB,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAE,CAAC,WAAW,CAAC;IACjD,CAAC;IAES,qBAAqB;QAC9B,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAE9C,OAAO,GAAG,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;IACxE,CAAC;IAES,iBAAiB,CAAC,QAAgB;QAC3C,IAAI,IAAI,CAAC,KAAK,EAAE;YACf,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;SAC7E;QAED,OAAO,EAAE,CAAC;IACX,CAAC;IAES,MAAM,CAAC,OAAO,CAAC,IAAY,EAAE,QAAgB;QACtD,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAC;IACzC,CAAC;IAEO,gBAAgB;QACvB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAEhC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;CACD;AAzHD,sCAyHC"}
@@ -23,7 +23,7 @@ let SerializationTestSuite = class SerializationTestSuite extends tests_1.TestSu
23
23
  async baseExceptionFromError() {
24
24
  const message = 'Test message';
25
25
  const error = new Error(message);
26
- const exception = exceptions_1.BaseException.fromError(error);
26
+ const exception = exceptions_1.BaseException.normalize(error);
27
27
  (0, tests_1.expect)(exception).toBeInstanceOf(Error);
28
28
  (0, tests_1.expect)(exception).toBeInstanceOf(exceptions_1.BaseException);
29
29
  (0, tests_1.expect)(exception).toBeInstanceOf(exceptions_1.ErrorException);
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-error.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,qBAAa,uBAAwB,SAAQ,sBAAsB;gBAC/C,KAAK,EAAE,cAAc;CAqBxC"}
1
+ {"version":3,"file":"aggregate-error.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,qBAAa,uBAAwB,SAAQ,sBAAsB;gBAC/C,KAAK,EAAE,cAAc;CAiBxC"}
@@ -6,14 +6,10 @@ export class AggregateErrorException extends BaseAggregateException {
6
6
  super(errors
7
7
  .map(error => {
8
8
  if (error instanceof AggregateError) {
9
- BaseAggregateException.fromError(error);
9
+ BaseAggregateException.normalize(error);
10
10
  }
11
- if (error instanceof Error) {
12
- return BaseException.fromError(error);
13
- }
14
- return null;
15
- })
16
- .filter((exception) => exception !== null), error.message);
11
+ return BaseException.normalize(error);
12
+ }), error.message);
17
13
  this.stack = error.stack;
18
14
  }
19
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-error.exception.js","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,OAAO,uBAAwB,SAAQ,sBAAsB;IAClE,YAAmB,KAAqB;QACvC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,KAAK,CACJ,MAAM;aACJ,GAAG,CAAC,KAAK,CAAC,EAAE;YACZ,IAAI,KAAK,YAAY,cAAc,EAAE;gBACpC,sBAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACxC;YACD,IAAI,KAAK,YAAY,KAAK,EAAE;gBAC3B,OAAO,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACtC;YAED,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,SAAS,EAA8B,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,EACvE,KAAK,CAAC,OAAO,CACb,CAAC;QAED,IAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACnC,CAAC;CACD"}
1
+ {"version":3,"file":"aggregate-error.exception.js","sourceRoot":"","sources":["../../src/exceptions/aggregate-error.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,OAAO,uBAAwB,SAAQ,sBAAsB;IAClE,YAAmB,KAAqB;QACvC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEzB,KAAK,CACJ,MAAM;aACJ,GAAG,CAAC,KAAK,CAAC,EAAE;YACZ,IAAI,KAAK,YAAY,cAAc,EAAE;gBACpC,sBAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACxC;YAED,OAAO,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC,CAAC,EACH,KAAK,CAAC,OAAO,CACb,CAAC;QAED,IAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACnC,CAAC;CACD"}
@@ -7,7 +7,7 @@ export declare abstract class BaseAggregateException extends BaseException {
7
7
  readonly exceptions: BaseException[];
8
8
  protected constructor(exceptions: BaseException[], message: string, options?: BaseAggregateExceptionOptions);
9
9
  toJSON(): JSONBaseAggregateException;
10
- static fromError(error: AggregateError): BaseAggregateException;
10
+ static normalize(error: AggregateError): BaseAggregateException;
11
11
  protected injectBeforeStack(padCount: number): string[];
12
12
  }
13
13
  //# sourceMappingURL=base.aggregate.exception.d.ts.map
@@ -13,7 +13,7 @@ export class BaseAggregateException extends BaseException {
13
13
  exceptions: this.exceptions.map(exception => exception.toJSON()),
14
14
  };
15
15
  }
16
- static fromError(error) {
16
+ static normalize(error) {
17
17
  return new AggregateErrorException(error);
18
18
  }
19
19
  injectBeforeStack(padCount) {
@@ -27,7 +27,7 @@ export declare abstract class BaseException extends Error {
27
27
  isFromNextTick(): boolean;
28
28
  isFromImmediate(): boolean;
29
29
  isFromTimer(): boolean;
30
- static fromError(error: Error): BaseException;
30
+ static normalize(error: unknown, defaultMessage?: string): BaseException;
31
31
  protected getCtor(): Function;
32
32
  protected getStringifyFirstLine(): string;
33
33
  protected injectBeforeStack(padCount: number): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"base.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/base.exception.ts"],"names":[],"mappings":";;AACA,OAAO,EACN,sBAAsB,EACtB,OAAO,EACP,MAAM,MAAM,CAAC;AAKd,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,8BAAsB,aAAc,SAAQ,KAAK;IAChD,SAAgB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAQ;IAC9C,SAAyB,KAAK,EAAE,MAAM,CAAC;IACvC,SAAyB,OAAO,EAAE,MAAM,CAAC;IAC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ClC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,8BAAsB,aAAc,SAAQ,KAAK;IAChD,SAAgB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAQ;IAC9C,SAAyB,KAAK,EAAE,MAAM,CAAC;IACvC,SAAyB,OAAO,EAAE,MAAM,CAAC;IACzC,SAAyB,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/C,OAAO,CAAC,UAAU,CAAqC;gBAEpC,OAAO,EAAE,MAAM,EAAE,aAAa,GAAE,gBAAqB;IAexE,IAAoB,IAAI,IAAI,MAAM,CAIjC;IAEM,MAAM,IAAI,iBAAiB;IAmBlB,QAAQ,CAAC,QAAQ,SAAsB,GAAG,MAAM;IAazD,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,sBAAsB,GAAG,MAAM;IAIvF,cAAc,IAAI,OAAO;IAMzB,eAAe,IAAI,OAAO;IAM1B,WAAW,IAAI,OAAO;WAMf,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,SAAuB,GAAG,aAAa;IAY7F,SAAS,CAAC,OAAO,IAAI,QAAQ;IAI7B,SAAS,CAAC,qBAAqB,IAAI,MAAM;IAMzC,SAAS,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAQvD,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIhE,OAAO,CAAC,gBAAgB;CAKxB"}
@@ -1,4 +1,4 @@
1
- import * as os from 'os';
1
+ import os from 'os';
2
2
  import { inspect, } from 'util';
3
3
  import { StackTraceFormatter } from '../utils';
4
4
  import { ErrorException } from './error.exception';
@@ -64,8 +64,14 @@ export class BaseException extends Error {
64
64
  const lastLine = this.getLastStackLine();
65
65
  return lastLine.includes('Timeout._onTimeout');
66
66
  }
67
- static fromError(error) {
68
- return new ErrorException(error);
67
+ static normalize(error, defaultMessage = 'Unknown error type') {
68
+ if (error instanceof BaseException) {
69
+ return error;
70
+ }
71
+ if (error instanceof Error) {
72
+ return new ErrorException(error);
73
+ }
74
+ return new ErrorException(new Error(defaultMessage, { cause: error }));
69
75
  }
70
76
  getCtor() {
71
77
  return Object.getPrototypeOf(this).constructor;
@@ -1 +1 @@
1
- {"version":3,"file":"base.exception.js","sourceRoot":"","sources":["../../src/exceptions/base.exception.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAEN,OAAO,GACP,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAenD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,MAAM,OAAgB,aAAc,SAAQ,KAAK;IAChC,IAAI,GAAqB,IAAI,CAAC;IACrB,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,KAAK,CAAiB;IACvC,UAAU,GAAgC,IAAI,CAAC;IAEvD,YAAmB,OAAe,EAAE,gBAAkC,EAAE;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,aAAa,CAAC,KAAK,EAAE;YACxB,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;SACjC;QACD,IAAI,aAAa,CAAC,IAAI,EAAE;YACvB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;SAC/B;QAED,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAoB,IAAI;QACvB,MAAM,EAAE,IAAI,EA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ACvB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAEhC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;CACD"}
@@ -20,7 +20,7 @@ let SerializationTestSuite = class SerializationTestSuite extends TestSuite {
20
20
  async baseExceptionFromError() {
21
21
  const message = 'Test message';
22
22
  const error = new Error(message);
23
- const exception = BaseException.fromError(error);
23
+ const exception = BaseException.normalize(error);
24
24
  expect(exception).toBeInstanceOf(Error);
25
25
  expect(exception).toBeInstanceOf(BaseException);
26
26
  expect(exception).toBeInstanceOf(ErrorException);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hg-ts/exception",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist-esm/index.js",
6
6
  "repository": "git@gitlab.com:hyper-graph/framework.git",
@@ -15,12 +15,12 @@
15
15
  "test:coverage": "hg test:coverage"
16
16
  },
17
17
  "devDependencies": {
18
- "@hg-ts-config/eslint-config": "0.1.39",
19
- "@hg-ts-config/nyc": "0.1.39",
20
- "@hg-ts-config/typescript": "0.1.39",
21
- "@hg-ts/cli": "0.1.39",
22
- "@hg-ts/tests": "0.1.39",
23
- "@hg-ts/types": "0.1.39",
18
+ "@hg-ts-config/eslint-config": "0.1.41",
19
+ "@hg-ts-config/nyc": "0.1.41",
20
+ "@hg-ts-config/typescript": "0.1.41",
21
+ "@hg-ts/cli": "0.1.41",
22
+ "@hg-ts/tests": "0.1.41",
23
+ "@hg-ts/types": "0.1.41",
24
24
  "@types/node": "20.8.7",
25
25
  "@typescript-eslint/eslint-plugin": "6.8.0",
26
26
  "@typescript-eslint/parser": "6.8.0",
@@ -9,15 +9,11 @@ export class AggregateErrorException extends BaseAggregateException {
9
9
  errors
10
10
  .map(error => {
11
11
  if (error instanceof AggregateError) {
12
- BaseAggregateException.fromError(error);
13
- }
14
- if (error instanceof Error) {
15
- return BaseException.fromError(error);
12
+ BaseAggregateException.normalize(error);
16
13
  }
17
14
 
18
- return null;
19
- })
20
- .filter((exception): exception is BaseException => exception !== null),
15
+ return BaseException.normalize(error);
16
+ }),
21
17
  error.message,
22
18
  );
23
19
 
@@ -34,7 +34,7 @@ export abstract class BaseAggregateException extends BaseException {
34
34
  };
35
35
  }
36
36
 
37
- public static override fromError(error: AggregateError): BaseAggregateException {
37
+ public static override normalize(error: AggregateError): BaseAggregateException {
38
38
  return new AggregateErrorException(error);
39
39
  }
40
40
 
@@ -1,4 +1,4 @@
1
- import * as os from 'os';
1
+ import os from 'os';
2
2
  import {
3
3
  InspectOptionsStylized,
4
4
  inspect,
@@ -104,8 +104,16 @@ export abstract class BaseException extends Error {
104
104
  return lastLine.includes('Timeout._onTimeout');
105
105
  }
106
106
 
107
- public static fromError(error: Error): BaseException {
108
- return new ErrorException(error);
107
+ public static normalize(error: unknown, defaultMessage = 'Unknown error type'): BaseException {
108
+ if (error instanceof BaseException) {
109
+ return error;
110
+ }
111
+
112
+ if (error instanceof Error) {
113
+ return new ErrorException(error);
114
+ }
115
+
116
+ return new ErrorException(new Error(defaultMessage, { cause: error }));
109
117
  }
110
118
 
111
119
  protected getCtor(): Function {
@@ -34,7 +34,7 @@ export class SerializationTestSuite extends TestSuite {
34
34
  public async baseExceptionFromError(): Promise<void> {
35
35
  const message = 'Test message';
36
36
  const error = new Error(message);
37
- const exception = BaseException.fromError(error);
37
+ const exception = BaseException.normalize(error);
38
38
 
39
39
  expect(exception).toBeInstanceOf(Error);
40
40
  expect(exception).toBeInstanceOf(BaseException);