Skip to content

Commit 1696250

Browse files
committed
Support for other types than Error in cause
1 parent cc4cbf2 commit 1696250

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed

dist/elmahio.js

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/elmahio.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/elmahio.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/elmahio.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/elmahio.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,29 @@
10241024
obj.StackTrace = objectLength(error.stack) !== 0 ? ErrorStackParser.parse(error) : null;
10251025
obj.Source = stack && stack.length > 0 ? stack[0].fileName : null;
10261026
obj.Inners = error.cause && typeof error.cause === "object" && error.cause instanceof Error ? [inspectorObj(error.cause)] : [];
1027+
1028+
if (error.cause && obj.Inners instanceof Array && obj.Inners.length === 0) {
1029+
if (typeof error.cause === "number" || typeof error.cause === "string" || typeof error.cause === "boolean") {
1030+
obj.ExceptionSpecific = [{ key: "cause", value: error.cause }];
1031+
}
1032+
if (typeof error.cause === "function") {
1033+
obj.ExceptionSpecific = [{ key: "cause", value: error.cause.toString() }];
1034+
}
1035+
if (typeof error.cause === "object") {
1036+
if (!(Object.keys(obj).length === 0 && obj.constructor === Object)) {
1037+
let objEntries = [];
1038+
for (const [key, value] of Object.entries(error.cause)) {
1039+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
1040+
objEntries.push({ key: key, value: value });
1041+
} else {
1042+
objEntries.push({ key: key, value: value.toString() });
1043+
}
1044+
}
1045+
obj.ExceptionSpecific = objEntries;
1046+
}
1047+
}
1048+
}
1049+
10271050
} else {
10281051
obj.Type = typeof fullError.error || null;
10291052
obj.Message = fullError.message || null;

0 commit comments

Comments
 (0)