diff --git a/packages/desktop/electron/preload.js b/packages/desktop/electron/preload.js index 8babfb6625f..6c20decca7a 100644 --- a/packages/desktop/electron/preload.js +++ b/packages/desktop/electron/preload.js @@ -2,7 +2,14 @@ const { ipcRenderer, contextBridge } = require('electron') // Hook the error handlers as early as possible window.addEventListener('error', event => { - ipcRenderer.invoke('handle-error', "Preload Context Error", event.error || event) + if (event.error && event.error.message) { + ipcRenderer.invoke('handle-error', "Preload Context Error", { + message: event.error.message, + stack: event.error.stack + }) + } else { + ipcRenderer.invoke('handle-error', "Preload Context Error", event.error || event) + } event.preventDefault(); console.error(event.error || event) }) diff --git a/packages/desktop/main.js b/packages/desktop/main.js index 3ef0a71fc3e..cac5a290199 100644 --- a/packages/desktop/main.js +++ b/packages/desktop/main.js @@ -2,7 +2,14 @@ import { Electron } from 'shared/lib/electron' import App from './App.svelte' window.addEventListener('error', event => { - Electron.unhandledException("Render Context Error", event.error || event) + if (event.error && event.error.message) { + Electron.unhandledException("Render Context Error", { + message: event.error.message, + stack: event.error.stack + }) + } else { + Electron.unhandledException("Render Context Error", event.error || event) + } event.preventDefault(); console.error(event.error || event) }) diff --git a/packages/desktop/public/error.html b/packages/desktop/public/error.html index 45ab0c88eb4..d5196669801 100644 --- a/packages/desktop/public/error.html +++ b/packages/desktop/public/error.html @@ -109,14 +109,16 @@ } ::-webkit-scrollbar { - width: 8px; + width: 8px; } + ::-webkit-scrollbar-thumb { - background-color: #D8E3F5; - border-radius: 10px; + background-color: #D8E3F5; + border-radius: 10px; } + ::-webkit-scrollbar-track { - background-color: transparent; + background-color: transparent; } @@ -159,14 +161,34 @@

Unfortunately an error has occurred in Firefly.

document.getElementById('version').textContent = `App Version: ${errorData.version}` document.getElementById('diagnostics').textContent = errorData.diagnostics document.getElementById('errorType').textContent = `Error Type: ${errorData.errorType}` - document.getElementById('details').textContent = JSON.stringify(errorData.error || "") + document.getElementById('details').textContent = formatError() }) + function formatError() { + let formatted = [] + + if (errorData.error) { + if (errorData.error instanceof Error || errorData.error.stack || errorData.error.message) { + if (errorData.error.stack) { + formatted.push(errorData.error.stack) + } else if (errorData.error.message) { + formatted.push(errorData.error.message) + } + } else if (typeof errorData.error == 'string') { + formatted.push(errorData.error) + } else { + formatted.push(JSON.stringify(errorData.error)) + } + } + + return formatted.join('\r\n') + } + function copy() { let content = `App Version: ${errorData.version}\r\n\r\n` content += errorData.diagnostics + "\r\n\r\n" content += `Error Type: ${errorData.errorType}` + "\r\n\r\n" - content += JSON.stringify(errorData.error || "") + content += formatError() copyToClipboard(content) } @@ -195,4 +217,4 @@

Unfortunately an error has occurred in Firefly.

- + \ No newline at end of file