From c81171a39eae97bddeb0c553a5233527930cbf99 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 27 Dec 2019 21:42:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=89=80=E6=9C=89=E6=9C=AA?= =?UTF-8?q?=E6=8D=95=E8=8E=B7=E9=94=99=E8=AF=AF=E4=BA=8B=E4=BB=B6=E5=B9=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=88=B0=E6=97=A5=E5=BF=97=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/error.js | 12 ++++++++++++ src/main/index.js | 1 + src/renderer/main.js | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 src/common/error.js diff --git a/src/common/error.js b/src/common/error.js new file mode 100644 index 00000000..5ea68a9a --- /dev/null +++ b/src/common/error.js @@ -0,0 +1,12 @@ +const { log } = require('./utils') + +process.on('uncaughtException', function(err) { + console.error('An uncaught error occurred!') + console.error(err) + log.error(err) +}) +process.on('unhandledRejection', (reason, p) => { + console.error('Unhandled Rejection at: Promise ', p) + console.error(' reason: ', reason) + log.error(reason) +}) diff --git a/src/main/index.js b/src/main/index.js index c6320a2d..88cbfe03 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -15,6 +15,7 @@ app.on('second-instance', (event, argv, cwd) => { } }) +require('../common/error') require('./events') const autoUpdate = require('./utils/autoUpdate') const { isLinux, isMac } = require('../common/utils') diff --git a/src/renderer/main.js b/src/renderer/main.js index 67630453..01337afb 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -11,6 +11,8 @@ import App from './App' import router from './route' import store from './store' +import '../common/error' + sync(store, router) if (!process.env.IS_WEB) {