File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -290,8 +290,7 @@ function getNonErrorObjectExceptionValue(
290
290
) : string {
291
291
const keys = extractExceptionKeysForMessage ( exception ) ;
292
292
const captureType = isUnhandledRejection ? 'promise rejection' : 'exception' ;
293
- const prototype : Prototype | null = Object . getPrototypeOf ( exception ) ;
294
- const className = prototype ? prototype . constructor . name : undefined ;
293
+ const className = getObjectClassName ( exception ) ;
295
294
296
295
// Some ErrorEvent instances do not have an `error` property, which is why they are not handled before
297
296
// We still want to try to get a decent message for these cases
@@ -309,3 +308,12 @@ function getNonErrorObjectExceptionValue(
309
308
310
309
return `${ label } with keys: ${ keys } ` ;
311
310
}
311
+
312
+ function getObjectClassName ( obj : unknown ) : string | undefined | void {
313
+ try {
314
+ const prototype : Prototype | null = Object . getPrototypeOf ( obj ) ;
315
+ return prototype ? prototype . constructor . name : undefined ;
316
+ } catch ( e ) {
317
+ // ignore errors here
318
+ }
319
+ }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ function isBuiltin(wat: unknown, className: string): boolean {
41
41
* @param wat A value to be checked.
42
42
* @returns A boolean representing the result.
43
43
*/
44
- export function isErrorEvent ( wat : unknown ) : wat is ErrorEvent {
44
+ export function isErrorEvent ( wat : unknown ) : boolean {
45
45
return isBuiltin ( wat , 'ErrorEvent' ) ;
46
46
}
47
47
You can’t perform that action at this time.
0 commit comments