Skip to content

Commit a3fb285

Browse files
feat(browser): Add DOMException.code as tag if it exists (#3018)
* add code as tag * Update packages/browser/src/eventbuilder.ts Co-authored-by: Kamil Ogórek <[email protected]>
1 parent 600df15 commit a3fb285

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/browser/src/eventbuilder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function eventFromUnknownInput(
7878
}
7979
if (isDOMError(exception as DOMError) || isDOMException(exception as DOMException)) {
8080
// If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
81-
// then we just extract the name and message, as they don't provide anything else
81+
// then we just extract the name, code, and message, as they don't provide anything else
8282
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
8383
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
8484
const domException = exception as DOMException;
@@ -87,6 +87,10 @@ export function eventFromUnknownInput(
8787

8888
event = eventFromString(message, syntheticException, options);
8989
addExceptionTypeValue(event, message);
90+
if ('code' in domException) {
91+
event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` }
92+
}
93+
9094
return event;
9195
}
9296
if (isError(exception as Error)) {

0 commit comments

Comments
 (0)