Skip to content

Commit 9e08fb6

Browse files
committed
PR feedback
1 parent 0e6cf14 commit 9e08fb6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/browser/src/eventbuilder.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
}

packages/utils/src/is.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)