Skip to content
handleError.js 810 B
Newer Older
Amaury Martiny's avatar
Amaury Martiny committed
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: MIT

Amaury Martiny's avatar
Amaury Martiny committed
const { app, dialog } = require('electron');
Amaury Martiny's avatar
Amaury Martiny committed
const { bugs: { url }, parity: { channel } } = require('../../package.json');
Amaury Martiny's avatar
Amaury Martiny committed
const pino = require('../utils/pino')();
Amaury Martiny's avatar
Amaury Martiny committed

module.exports = (err, message = 'An error occurred.') => {
Amaury Martiny's avatar
Amaury Martiny committed
  pino.error(err);
Amaury Martiny's avatar
Amaury Martiny committed
  dialog.showMessageBox(
    {
      buttons: ['OK'],
      detail: `Please attach the following debugging info:
OS: ${process.platform}
Arch: ${process.arch}
Channel: ${channel}
Error: ${err.message}

Please also attach the contents of the following file:
Amaury Martiny's avatar
Amaury Martiny committed
${app.getPath('userData')}/parity.log`,
      message: `${message} Please file an issue at ${url}.`,
Amaury Martiny's avatar
Amaury Martiny committed
      title: 'Parity Error',
      type: 'error'
    },
    () => app.exit(1)
  );
};