@diia-inhouse/errors 2.2.31 → 2.3.0

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.
@@ -11,8 +11,13 @@ declare class ApiError extends Error {
11
11
  getData(): ErrorData;
12
12
  getName(): string;
13
13
  getMessage(): string;
14
+ setType(type: ErrorType): void;
14
15
  getType(): ErrorType;
15
16
  /**
17
+ * Returns the error type of the original error (ApiError.getData().opOriginalError?.type).
18
+ */
19
+ getOriginalType(): ErrorType | undefined;
20
+ /**
16
21
  * Checks if the error type (ApiError.getType()) is an external error.
17
22
  */
18
23
  isExternal(): boolean;
@@ -12,7 +12,6 @@ var ApiError = class extends Error {
12
12
  if (processCode) {
13
13
  this.data.processCode = processCode;
14
14
  this.data.code ??= code;
15
- this.type = type || "unoperated";
16
15
  }
17
16
  if (!message) message = "Something went wrong. Please try again.";
18
17
  this.message = message;
@@ -30,10 +29,19 @@ var ApiError = class extends Error {
30
29
  getMessage() {
31
30
  return this.message;
32
31
  }
32
+ setType(type) {
33
+ this.type = type;
34
+ }
33
35
  getType() {
34
36
  return this.type;
35
37
  }
36
38
  /**
39
+ * Returns the error type of the original error (ApiError.getData().opOriginalError?.type).
40
+ */
41
+ getOriginalType() {
42
+ return this.data.opOriginalError?.type;
43
+ }
44
+ /**
37
45
  * Checks if the error type (ApiError.getType()) is an external error.
38
46
  */
39
47
  isExternal() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diia-inhouse/errors",
3
- "version": "2.2.31",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
5
  "description": "Custom errors",
6
6
  "main": "dist/index.js",