@likec4/core 0.54.0 → 0.56.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.
|
@@ -27,13 +27,7 @@ export declare function nonNullable<T>(value: T, message?: string): T & {};
|
|
|
27
27
|
export declare class RelationRefError extends BaseError {
|
|
28
28
|
constructor(message: string, options?: BaseErrorOptions);
|
|
29
29
|
}
|
|
30
|
-
export declare function normalizeError(e: unknown):
|
|
31
|
-
export declare function serializeError(e: unknown): {
|
|
32
|
-
name: string;
|
|
33
|
-
message: string;
|
|
34
|
-
error: BaseError;
|
|
35
|
-
};
|
|
36
|
-
export declare function throwNormalizedError(e: unknown): never;
|
|
30
|
+
export declare function normalizeError(e: unknown): Error;
|
|
37
31
|
export declare function invariant(condition: any, message?: string): asserts condition;
|
|
38
32
|
export declare class NonExhaustiveError extends BaseError {
|
|
39
33
|
constructor(message: string, options?: BaseErrorOptions);
|
package/dist/cjs/errors/index.js
CHANGED
|
@@ -9,8 +9,6 @@ exports.invariant = invariant;
|
|
|
9
9
|
exports.nonNullable = nonNullable;
|
|
10
10
|
exports.nonexhaustive = nonexhaustive;
|
|
11
11
|
exports.normalizeError = normalizeError;
|
|
12
|
-
exports.serializeError = serializeError;
|
|
13
|
-
exports.throwNormalizedError = throwNormalizedError;
|
|
14
12
|
var _safeStableStringify = _interopRequireDefault(require("safe-stable-stringify"));
|
|
15
13
|
var _tsCustomError = require("ts-custom-error");
|
|
16
14
|
var _guards = require("../utils/guards");
|
|
@@ -76,30 +74,13 @@ class RelationRefError extends BaseError {
|
|
|
76
74
|
}
|
|
77
75
|
exports.RelationRefError = RelationRefError;
|
|
78
76
|
function normalizeError(e) {
|
|
79
|
-
if (e instanceof BaseError) {
|
|
77
|
+
if (e instanceof BaseError || e instanceof Error) {
|
|
80
78
|
return e;
|
|
81
79
|
}
|
|
82
|
-
if (e instanceof Error) {
|
|
83
|
-
return new UnknownError(e.message, {
|
|
84
|
-
cause: e
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (e === null || e === void 0) {
|
|
88
|
-
return new UnknownError("Undefined error");
|
|
89
|
-
}
|
|
90
80
|
const message = (0, _guards.isString)(e) ? e : (0, _safeStableStringify.default)(e);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const error = normalizeError(e);
|
|
95
|
-
return {
|
|
96
|
-
name: error.name,
|
|
97
|
-
message: error.stack ? error.stack : `${error.name}: ${error.message}`,
|
|
98
|
-
error
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function throwNormalizedError(e) {
|
|
102
|
-
throw normalizeError(e);
|
|
81
|
+
const error = new UnknownError(message);
|
|
82
|
+
Error.captureStackTrace(error, normalizeError);
|
|
83
|
+
return error;
|
|
103
84
|
}
|
|
104
85
|
function invariant(condition, message) {
|
|
105
86
|
if (condition) {
|
|
@@ -27,13 +27,7 @@ export declare function nonNullable<T>(value: T, message?: string): T & {};
|
|
|
27
27
|
export declare class RelationRefError extends BaseError {
|
|
28
28
|
constructor(message: string, options?: BaseErrorOptions);
|
|
29
29
|
}
|
|
30
|
-
export declare function normalizeError(e: unknown):
|
|
31
|
-
export declare function serializeError(e: unknown): {
|
|
32
|
-
name: string;
|
|
33
|
-
message: string;
|
|
34
|
-
error: BaseError;
|
|
35
|
-
};
|
|
36
|
-
export declare function throwNormalizedError(e: unknown): never;
|
|
30
|
+
export declare function normalizeError(e: unknown): Error;
|
|
37
31
|
export declare function invariant(condition: any, message?: string): asserts condition;
|
|
38
32
|
export declare class NonExhaustiveError extends BaseError {
|
|
39
33
|
constructor(message: string, options?: BaseErrorOptions);
|
package/dist/esm/errors/index.js
CHANGED
|
@@ -44,28 +44,13 @@ export class RelationRefError extends BaseError {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
export function normalizeError(e) {
|
|
47
|
-
if (e instanceof BaseError) {
|
|
47
|
+
if (e instanceof BaseError || e instanceof Error) {
|
|
48
48
|
return e;
|
|
49
49
|
}
|
|
50
|
-
if (e instanceof Error) {
|
|
51
|
-
return new UnknownError(e.message, { cause: e });
|
|
52
|
-
}
|
|
53
|
-
if (e === null || e === void 0) {
|
|
54
|
-
return new UnknownError("Undefined error");
|
|
55
|
-
}
|
|
56
50
|
const message = isString(e) ? e : stringify(e);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const error = normalizeError(e);
|
|
61
|
-
return {
|
|
62
|
-
name: error.name,
|
|
63
|
-
message: error.stack ? error.stack : `${error.name}: ${error.message}`,
|
|
64
|
-
error
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export function throwNormalizedError(e) {
|
|
68
|
-
throw normalizeError(e);
|
|
51
|
+
const error = new UnknownError(message);
|
|
52
|
+
Error.captureStackTrace(error, normalizeError);
|
|
53
|
+
return error;
|
|
69
54
|
}
|
|
70
55
|
export function invariant(condition, message) {
|
|
71
56
|
if (condition) {
|
|
@@ -27,13 +27,7 @@ export declare function nonNullable<T>(value: T, message?: string): T & {};
|
|
|
27
27
|
export declare class RelationRefError extends BaseError {
|
|
28
28
|
constructor(message: string, options?: BaseErrorOptions);
|
|
29
29
|
}
|
|
30
|
-
export declare function normalizeError(e: unknown):
|
|
31
|
-
export declare function serializeError(e: unknown): {
|
|
32
|
-
name: string;
|
|
33
|
-
message: string;
|
|
34
|
-
error: BaseError;
|
|
35
|
-
};
|
|
36
|
-
export declare function throwNormalizedError(e: unknown): never;
|
|
30
|
+
export declare function normalizeError(e: unknown): Error;
|
|
37
31
|
export declare function invariant(condition: any, message?: string): asserts condition;
|
|
38
32
|
export declare class NonExhaustiveError extends BaseError {
|
|
39
33
|
constructor(message: string, options?: BaseErrorOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"rambdax": "^9.1.1",
|
|
81
|
-
"remeda": "^1.
|
|
81
|
+
"remeda": "^1.40.1",
|
|
82
82
|
"safe-stable-stringify": "^2.4.3",
|
|
83
83
|
"ts-custom-error": "^3.3.1"
|
|
84
84
|
},
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"execa": "^8.0.1",
|
|
87
87
|
"typescript": "^5.3.3",
|
|
88
88
|
"unbuild": "^2.0.0",
|
|
89
|
-
"vitest": "^1.
|
|
89
|
+
"vitest": "^1.2.2"
|
|
90
90
|
},
|
|
91
|
-
"packageManager": "yarn@4.0
|
|
91
|
+
"packageManager": "yarn@4.1.0",
|
|
92
92
|
"volta": {
|
|
93
93
|
"extends": "../../package.json"
|
|
94
94
|
},
|