| 10 | process.on('unhandledRejection', showError); |
| 11 | |
| 12 | function showError(error: Error) { |
| 13 | const dialog = gui.MessageBox.create(); |
| 14 | dialog.setType('error'); |
| 15 | if (process.platform != 'darwin') |
| 16 | dialog.setTitle('Error'); |
| 17 | dialog.setText(error.message); |
| 18 | dialog.setInformativeText(error.stack); |
| 19 | dialog.addButton('Copy error', 0); |
| 20 | dialog.setDefaultResponse(0); |
| 21 | dialog.addButton('Close', -1); |
| 22 | if (dialog.run() == 0) |
| 23 | gui.Clipboard.get().setText(`${error.message}\n${error.stack}`); |
| 24 | if (quitOnException) { |
| 25 | gui.MessageLoop.quit(); |
| 26 | process.exit(1); |
| 27 | } |
| 28 | } |