Skip to content

Commit

Permalink
feat(browser): Add DOMException.code as tag if it exists (#3018)
Browse files Browse the repository at this point in the history
* add code as tag

* Update packages/browser/src/eventbuilder.ts

Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
  • Loading branch information
lobsterkatie and kamilogorek authored Nov 4, 2020
1 parent 600df15 commit a3fb285
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function eventFromUnknownInput(
}
if (isDOMError(exception as DOMError) || isDOMException(exception as DOMException)) {
// If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
// then we just extract the name and message, as they don't provide anything else
// then we just extract the name, code, and message, as they don't provide anything else
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
const domException = exception as DOMException;
Expand All @@ -87,6 +87,10 @@ export function eventFromUnknownInput(

event = eventFromString(message, syntheticException, options);
addExceptionTypeValue(event, message);
if ('code' in domException) {
event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` }
}

return event;
}
if (isError(exception as Error)) {
Expand Down

0 comments on commit a3fb285

Please sign in to comment.