@@ -73,17 +73,25 @@ export function eventFromUnknownInput(
73
73
event = eventFromStacktrace ( computeStackTrace ( exception as Error ) ) ;
74
74
return event ;
75
75
}
76
+
77
+ // If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
78
+ // and message, as it doesn't provide anything else. According to the spec, all `DOMExceptions` should also be
79
+ // `Error`s, but that's not the case in IE11, so in that case we treat it the same as we do a `DOMError`.
80
+ //
81
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMError
82
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMException
83
+ // https://webidl.spec.whatwg.org/#es-DOMException-specialness
76
84
if ( isDOMError ( exception as DOMError ) || isDOMException ( exception as DOMException ) ) {
77
- // If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
78
- // then we just extract the name, code, and message, as they don't provide anything else
79
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMError
80
- // https://developer.mozilla.org/en-US/docs/Web/API/DOMException
81
85
const domException = exception as DOMException ;
82
- const name = domException . name || ( isDOMError ( domException ) ? 'DOMError' : 'DOMException' ) ;
83
- const message = domException . message ? `${ name } : ${ domException . message } ` : name ;
84
86
85
- event = eventFromString ( message , syntheticException , options ) ;
86
- addExceptionTypeValue ( event , message ) ;
87
+ if ( 'stack' in ( exception as Error ) ) {
88
+ event = eventFromStacktrace ( computeStackTrace ( exception as Error ) ) ;
89
+ } else {
90
+ const name = domException . name || ( isDOMError ( domException ) ? 'DOMError' : 'DOMException' ) ;
91
+ const message = domException . message ? `${ name } : ${ domException . message } ` : name ;
92
+ event = eventFromString ( message , syntheticException , options ) ;
93
+ addExceptionTypeValue ( event , message ) ;
94
+ }
87
95
if ( 'code' in domException ) {
88
96
event . tags = { ...event . tags , 'DOMException.code' : `${ domException . code } ` } ;
89
97
}
0 commit comments