feat: log all errors [probably a bad idea]

This commit is contained in:
ThaUnknown 2023-08-22 15:40:57 +02:00
parent f93017fba3
commit d87e864c41
2 changed files with 18 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "4.3.8",
"version": "4.3.9",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"description": "Stream anime torrents, real-time with no waiting for downloads.",
"main": "build/main.js",

View file

@ -141,3 +141,20 @@ ipcRenderer.on('port', (e) => {
}
message = e.ports[0].postMessage.bind(e.ports[0])
})
const excludedErrorMessages = ['WebSocket']
function dispatchError (e) {
if (e instanceof ErrorEvent) return dispatchError(e.error)
if (e instanceof PromiseRejectionEvent) return dispatchError(e.reason)
for (const exclude of excludedErrorMessages) {
if (e.message?.startsWith(exclude)) return
}
client?.dispatch('error', e)
}
process.on('uncaughtException', dispatchError)
window.addEventListener('error', dispatchError)
window.addEventListener('unhandledrejection', dispatchError)