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(
290290) : string {
291291 const keys = extractExceptionKeysForMessage ( exception ) ;
292292 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 ) ;
295294
296295 // Some ErrorEvent instances do not have an `error` property, which is why they are not handled before
297296 // We still want to try to get a decent message for these cases
@@ -309,3 +308,12 @@ function getNonErrorObjectExceptionValue(
309308
310309 return `${ label } with keys: ${ keys } ` ;
311310}
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 {
4141 * @param wat A value to be checked.
4242 * @returns A boolean representing the result.
4343 */
44- export function isErrorEvent ( wat : unknown ) : wat is ErrorEvent {
44+ export function isErrorEvent ( wat : unknown ) : boolean {
4545 return isBuiltin ( wat , 'ErrorEvent' ) ;
4646}
4747
You can’t perform that action at this time.
0 commit comments