@lightsparkdev/core 1.0.15 → 1.0.16
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/CHANGELOG.md +6 -0
- package/dist/{chunk-ZLX5HJ4C.js → chunk-JTLRW26V.js} +5 -1
- package/dist/index.cjs +5 -1
- package/dist/index.js +1 -1
- package/dist/utils/index.cjs +5 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/src/utils/errors.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -732,9 +732,13 @@ function errorToJSON(err) {
|
|
|
732
732
|
if (!err) {
|
|
733
733
|
return null;
|
|
734
734
|
}
|
|
735
|
-
if (typeof err === "object" &&
|
|
735
|
+
if (typeof err === "object" && "toJSON" in err && typeof err.toJSON === "function") {
|
|
736
736
|
return err.toJSON();
|
|
737
737
|
}
|
|
738
|
+
if (typeof err === "object" && /* This happens for certain errors like DOMException: */
|
|
739
|
+
Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
|
|
740
|
+
return { message: err.message };
|
|
741
|
+
}
|
|
738
742
|
return JSON.parse(
|
|
739
743
|
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
740
744
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -1135,9 +1135,13 @@ function errorToJSON(err) {
|
|
|
1135
1135
|
if (!err) {
|
|
1136
1136
|
return null;
|
|
1137
1137
|
}
|
|
1138
|
-
if (typeof err === "object" &&
|
|
1138
|
+
if (typeof err === "object" && "toJSON" in err && typeof err.toJSON === "function") {
|
|
1139
1139
|
return err.toJSON();
|
|
1140
1140
|
}
|
|
1141
|
+
if (typeof err === "object" && /* This happens for certain errors like DOMException: */
|
|
1142
|
+
Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
|
|
1143
|
+
return { message: err.message };
|
|
1144
|
+
}
|
|
1141
1145
|
return JSON.parse(
|
|
1142
1146
|
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
1143
1147
|
);
|
package/dist/index.js
CHANGED
package/dist/utils/index.cjs
CHANGED
|
@@ -807,9 +807,13 @@ function errorToJSON(err) {
|
|
|
807
807
|
if (!err) {
|
|
808
808
|
return null;
|
|
809
809
|
}
|
|
810
|
-
if (typeof err === "object" &&
|
|
810
|
+
if (typeof err === "object" && "toJSON" in err && typeof err.toJSON === "function") {
|
|
811
811
|
return err.toJSON();
|
|
812
812
|
}
|
|
813
|
+
if (typeof err === "object" && /* This happens for certain errors like DOMException: */
|
|
814
|
+
Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
|
|
815
|
+
return { message: err.message };
|
|
816
|
+
}
|
|
813
817
|
return JSON.parse(
|
|
814
818
|
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
815
819
|
);
|
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
package/src/utils/errors.ts
CHANGED
|
@@ -43,12 +43,22 @@ export function errorToJSON(err: unknown) {
|
|
|
43
43
|
}
|
|
44
44
|
if (
|
|
45
45
|
typeof err === "object" &&
|
|
46
|
-
err !== null &&
|
|
47
46
|
"toJSON" in err &&
|
|
48
47
|
typeof err.toJSON === "function"
|
|
49
48
|
) {
|
|
50
49
|
return err.toJSON() as JSONType;
|
|
51
50
|
}
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
typeof err === "object" &&
|
|
54
|
+
/* This happens for certain errors like DOMException: */
|
|
55
|
+
Object.getOwnPropertyNames(err).length === 0 &&
|
|
56
|
+
"message" in err &&
|
|
57
|
+
typeof err.message === "string"
|
|
58
|
+
) {
|
|
59
|
+
return { message: err.message };
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
return JSON.parse(
|
|
53
63
|
JSON.stringify(err, Object.getOwnPropertyNames(err)),
|
|
54
64
|
) as JSONType;
|