parent
8c325c901a
commit
7ef016f3f0
1 changed files with 18 additions and 14 deletions
|
@ -64,8 +64,10 @@ const createHandler =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
return typeof window !== 'undefined'
|
||||||
return window?.[globalVariableNames.notifications]?.notify[type](...args)
|
? // @ts-ignore
|
||||||
|
window[globalVariableNames.notifications]?.notify[type](...args)
|
||||||
|
: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export const notify: Notifiers = {
|
export const notify: Notifiers = {
|
||||||
|
@ -75,16 +77,18 @@ export const notify: Notifiers = {
|
||||||
error: createHandler('error'),
|
error: createHandler('error'),
|
||||||
}
|
}
|
||||||
|
|
||||||
window?.addEventListener('error', (e) => {
|
if (typeof window !== 'undefined') {
|
||||||
notify.error(
|
window.addEventListener('error', (e) => {
|
||||||
`An error occurred`,
|
notify.error(
|
||||||
`<pre>${e.message}</pre>\n\nSee **console** for details.`,
|
`An error occurred`,
|
||||||
)
|
`<pre>${e.message}</pre>\n\nSee **console** for details.`,
|
||||||
})
|
)
|
||||||
|
})
|
||||||
|
|
||||||
window?.addEventListener('unhandledrejection', (e) => {
|
window.addEventListener('unhandledrejection', (e) => {
|
||||||
notify.error(
|
notify.error(
|
||||||
`An error occurred`,
|
`An error occurred`,
|
||||||
`<pre>${e.reason}</pre>\n\nSee **console** for details.`,
|
`<pre>${e.reason}</pre>\n\nSee **console** for details.`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue