Skip to content

Commit

Permalink
use isError util
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Oct 23, 2024
1 parent 619799e commit a8e0008
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,14 @@ function onUnhandledRejection(ev: WindowEventMap['unhandledrejection']): void {
return
}

if (
!reason ||
!(reason instanceof Error) ||
typeof reason.stack !== 'string'
) {
if (!isError(reason)) {
// A non-error was thrown, we don't have anything to show. :-(
return
}

const e = reason
rejectionQueue.push(e)
rejectionQueue.push(reason)
for (const handler of rejectionHandlers) {
handler(e)
handler(reason)
}
}

Expand All @@ -99,7 +94,6 @@ export function handleGlobalErrors() {
} catch {}

window.addEventListener('error', onUnhandledError)

window.addEventListener('unhandledrejection', onUnhandledRejection)
}
}

0 comments on commit a8e0008

Please sign in to comment.