Permalink
Browse files

Include a button to report an error in error dialogs (#571)

  • Loading branch information...
sindresorhus committed Nov 19, 2018
1 parent 4126510 commit c65a2c9055da6f34558be497faa5b5721583310a
Showing with 44 additions and 29 deletions.
  1. +8 −2 app/index.js
  2. +1 −1 app/package.json
  3. +2 −3 app/renderer/components/SwapList.js
  4. +8 −2 app/renderer/index.js
  5. +2 −4 app/renderer/views/LoginBox.js
  6. +4 −0 app/util.js
  7. +10 −9 app/yarn.lock
  8. +1 −1 package.json
  9. +8 −7 yarn.lock
@@ -14,19 +14,25 @@ const {is, disableZoom, setContentSecurityPolicy} = require('electron-util');
const serve = require('electron-serve');
const logger = require('electron-timber');
const ipc = require('electron-better-ipc');
const unhandled = require('electron-unhandled');
const appMenu = require('./menu');
const config = require('./config');
const marketmaker = require('./marketmaker');
const {loginWindowSize} = require('./constants');
const {isDevelopment} = require('./util-common');
const {reportError} = require('./util');
const rendererState = require('./renderer-state');
require('electron-unhandled')({
showDialog: !isDevelopment,
unhandled({
reportButton: error => {
reportError(error.stack);
},
});
require('electron-debug')({
enabled: isDevelopment,
});
require('electron-context-menu')();
try {
@@ -23,7 +23,7 @@
"electron-serve": "^0.2.0",
"electron-store": "^2.0.0",
"electron-timber": "^0.5.1",
"electron-unhandled": "^1.1.0",
"electron-unhandled": "^2.1.0",
"electron-updater": "^3.2.2",
"electron-util": "^0.10.2",
"get-port": "^4.0.0",
@@ -1,4 +1,4 @@
import {api} from 'electron-util';
import unhandled from 'electron-unhandled';
import React from 'react';
import PropTypes from 'prop-types';
import {format as formatDate} from 'date-fns';
@@ -27,8 +27,7 @@ class CancelButton extends React.Component {
try {
await appContainer.api.cancelOrder(swapUuid);
} catch (error) {
console.error(error);
api.dialog.showErrorBox('Error', error.message);
unhandled.logError(error);
}
};
@@ -1,4 +1,6 @@
import {remote} from 'electron';
import {is} from 'electron-util';
import unhandled from 'electron-unhandled';
import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'unstated';
@@ -16,8 +18,12 @@ filterConsole([
UNSTATED.isEnabled = is.development;
UNSTATED.logStateChanges = false;
require('electron-unhandled')({
showDialog: !is.development,
unhandled({
reportButton: error => {
const {reportError} = remote.require('./util');
// FIXME: Have to pass the stack as Electron doesn't correctly serialize errors
reportError(error.stack);
},
});
// Enable OS specific styles
@@ -1,4 +1,4 @@
import {remote} from 'electron';
import unhandled from 'electron-unhandled';
import React from 'react';
import Button from 'components/Button';
import Input from 'components/Input';
@@ -14,7 +14,6 @@ import {translate} from '../translate';
import './LoginBox.scss';
const t = translate('login');
const {dialog} = remote;
const SettingsButton = () => (
<CogIcon
@@ -81,9 +80,8 @@ class LoginBox extends React.Component {
return;
}
console.error(error);
loginContainer.setActiveView(LoginBox.name);
dialog.showErrorBox('Login Failed', error.message || error || 'Unknown reason');
unhandled.logError(error, {title: 'Login Failed'});
}
};
@@ -15,3 +15,7 @@ ${debugInfo()}`;
openNewGitHubIssue({repoUrl, body});
};
exports.reportError = errorStack => {
exports.openGitHubIssue(`\`\`\`\n${errorStack}\n\`\`\`\n\n<!-- Please succinctly describe your issue and steps to reproduce it -->`);
};

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -22,7 +22,7 @@
"cycled": "^1.0.0",
"date-fns": "^1.29.0",
"delay": "^4.1.0",
"electron-unhandled": "^1.1.0",
"electron-unhandled": "^2.1.0",
"electron-util": "^0.10.2",
"emittery": "^0.4.1",
"filter-console": "^0.1.0",

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit c65a2c9

Please sign in to comment.