-
Notifications
You must be signed in to change notification settings - Fork 902
feat: handle errors better #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f69f6a3
815946c
e456859
f7bd836
0f91f54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| import { app, dialog } from 'electron' | ||||||
| import { app, dialog, shell } from 'electron' | ||||||
| import { join } from 'path' | ||||||
| import { store, createDaemon } from './utils' | ||||||
| import startupMenubar from './menubar' | ||||||
|
|
@@ -12,7 +12,30 @@ if (!app.requestSingleInstanceLock()) { | |||||
| ) | ||||||
|
|
||||||
| // No windows were opened at this time so we don't need to do app.quit() | ||||||
| process.exit(0) | ||||||
| process.exit(1) | ||||||
| } | ||||||
|
|
||||||
| function handleError (e) { | ||||||
| dialog.showMessageBox({ | ||||||
| type: 'error', | ||||||
| title: 'Something wrong happened', | ||||||
| message: e.stack + '\nPlease choose one of the options bellow. All of them will copy the error message to the clipboard.', | ||||||
| buttons: [ | ||||||
| 'Close', | ||||||
| 'Open logs', | ||||||
| 'Create a new issue' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The label could be more inviting and explicit on what will happen on click:
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only regards I have here is that it is the name of a button. We are lucky they're big on Windows, but I have no clue how they'll look around the other OSes.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| ] | ||||||
| }, option => { | ||||||
| if (option === 1) { | ||||||
| const path = app.getPath('userData') | ||||||
| shell.openItem(path) | ||||||
| } else if (option === 2) { | ||||||
| let text = 'Please describe what you were doing when this error happened.\n\n```\n' + e.stack + '\n```' | ||||||
|
hacdias marked this conversation as resolved.
Outdated
|
||||||
| shell.openExternal('https://github.com/ipfs-shipyard/ipfs-desktop/issues/new?body=' + encodeURI(text)) | ||||||
| } | ||||||
|
|
||||||
| process.exit(1) | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| async function setupConnection () { | ||||||
|
|
@@ -31,21 +54,30 @@ async function setupConnection () { | |||||
| } | ||||||
|
|
||||||
| async function run () { | ||||||
| await app.whenReady() | ||||||
|
|
||||||
| // Initial context object | ||||||
| let ctx = { | ||||||
| ipfsd: await setupConnection() | ||||||
| try { | ||||||
| await app.whenReady() | ||||||
| } catch (e) { | ||||||
| dialog.showErrorBox('Electron could not start', e.stack) | ||||||
| process.exit(1) | ||||||
| } | ||||||
|
|
||||||
| // Initialize windows. These can add properties to context | ||||||
| await startupMenubar(ctx) | ||||||
| try { | ||||||
| // Initial context object | ||||||
| let ctx = { | ||||||
| ipfsd: await setupConnection() | ||||||
| } | ||||||
|
|
||||||
| // Initialize windows. These can add properties to context | ||||||
| await startupMenubar(ctx) | ||||||
|
|
||||||
| // Register hooks | ||||||
| await registerHooks(ctx) | ||||||
| // Register hooks | ||||||
| await registerHooks(ctx) | ||||||
|
|
||||||
| if (!store.get('seenWelcome')) { | ||||||
| // TODO: open WebUI on Welcome screen | ||||||
| if (!store.get('seenWelcome')) { | ||||||
| // TODO: open WebUI on Welcome screen | ||||||
| } | ||||||
| } catch (e) { | ||||||
| handleError(e) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||



Uh oh!
There was an error while loading. Please reload this page.