Skip to content

Commit 7e536b8

Browse files
committed
always get error type from constructor name
1 parent 5543808 commit 7e536b8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/browser/src/eventbuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export function exceptionFromError(stackParser: StackParser, ex: Error): Excepti
2222
const frames = parseStackFrames(stackParser, ex);
2323

2424
const exception: Exception = {
25-
type: ex && ex.name,
25+
// This is necessary in order to get the name of user-defined errors which subclass `Error`
26+
type: ex && ex.constructor.name,
2627
value: extractMessage(ex),
2728
};
2829

packages/node/src/eventbuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export function parseStackFrames(stackParser: StackParser, error: Error): StackF
3030
*/
3131
export function exceptionFromError(stackParser: StackParser, error: Error): Exception {
3232
const exception: Exception = {
33-
type: error.name || error.constructor.name,
33+
// This is necessary in order to get the name of user-defined errors which subclass `Error`
34+
type: error.constructor.name,
3435
value: error.message,
3536
};
3637

0 commit comments

Comments
 (0)