@@ -76,17 +76,22 @@ export function eventFromUnknownInput(
76
76
event = eventFromStacktrace ( computeStackTrace ( exception as Error ) ) ;
77
77
return event ;
78
78
}
79
- if ( isDOMError ( exception as DOMError ) || isDOMException ( exception as DOMException ) ) {
79
+ if ( isDOMError ( exception ) || isDOMException ( exception ) ) {
80
80
// 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
82
82
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
83
83
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
84
- const domException = exception as DOMException ;
85
- const name = domException . name || ( isDOMError ( domException ) ? 'DOMError' : 'DOMException' ) ;
86
- const message = domException . message ? `${ name } : ${ domException . message } ` : name ;
87
84
88
- event = eventFromString ( message , syntheticException , options ) ;
89
- addExceptionTypeValue ( event , message ) ;
85
+ // eslint-disable-next-line prefer-const
86
+ let { name, code, message } = exception as DOMException ;
87
+ if ( ! name ) {
88
+ name = isDOMError ( exception ) ? 'DOMError' : 'DOMException' ;
89
+ name = code ? `${ name } (${ code } )` : name ;
90
+ }
91
+ const eventMessage = message ? `${ name } : ${ message } ` : name ;
92
+
93
+ event = eventFromString ( eventMessage , syntheticException , options ) ;
94
+ addExceptionTypeValue ( event , eventMessage ) ;
90
95
return event ;
91
96
}
92
97
if ( isError ( exception as Error ) ) {
0 commit comments