@dxos/errors 0.8.4-main.406dc2a → 0.8.4-main.548089c
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/lib/browser/index.mjs +16 -80
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +16 -80
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/base.d.ts +6 -11
- package/dist/types/src/base.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +48 -96
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/base.ts +7 -14
package/package.json
CHANGED
package/src/base.ts
CHANGED
|
@@ -45,19 +45,20 @@ export class BaseError<Code extends string = string> extends Error {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// NOTE: Errors go through odd transformations and the private fields seem to break.
|
|
49
|
+
code: Code;
|
|
50
|
+
context: Record<string, unknown>;
|
|
50
51
|
|
|
51
52
|
constructor(code: Code, options?: BaseErrorOptions) {
|
|
52
53
|
super(options?.message, { cause: options?.cause });
|
|
53
54
|
|
|
54
|
-
this
|
|
55
|
-
this
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.context = options?.context ?? {};
|
|
56
57
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
override get name() {
|
|
60
|
-
return this
|
|
61
|
+
return this.code;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/** Fallback message. */
|
|
@@ -65,16 +66,8 @@ export class BaseError<Code extends string = string> extends Error {
|
|
|
65
66
|
return this.constructor.name;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
get code(): Code {
|
|
69
|
-
return this.#code;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
69
|
// For effect error matching.
|
|
73
70
|
get _tag(): Code {
|
|
74
|
-
return this
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get context() {
|
|
78
|
-
return this.#context;
|
|
71
|
+
return this.code;
|
|
79
72
|
}
|
|
80
73
|
}
|