From ac2f99eb75ea0295dc08e47b91f4b4d54829d004 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 7 Feb 2016 12:01:40 +0100 Subject: Don't use process.exit, throw an error instead --- lib/webtorrent.js | 6 ++---- lib/webtorrentProcess.js | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/webtorrent.js b/lib/webtorrent.js index 5f10322a5..cb641fead 100644 --- a/lib/webtorrent.js +++ b/lib/webtorrent.js @@ -43,8 +43,7 @@ function create (options, callback) { // Run a timeout of 30s after which we exit the process var timeout_webtorrent_process = setTimeout(function () { - logger.error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.') - process.exit() + throw new Error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.') }, 30000) ipc.server.on(processKey + '.ready', function () { @@ -54,8 +53,7 @@ function create (options, callback) { }) ipc.server.on(processKey + '.exception', function (data) { - logger.error('Received exception error from webtorrent process.', { exception: data.exception }) - process.exit() + throw new Error('Received exception error from webtorrent process.' + data.exception) }) var webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true }) diff --git a/lib/webtorrentProcess.js b/lib/webtorrentProcess.js index 96ebf9d02..7ba2dd3d9 100644 --- a/lib/webtorrentProcess.js +++ b/lib/webtorrentProcess.js @@ -5,8 +5,7 @@ function webtorrent (args) { var ipc = require('node-ipc') if (args.length !== 3) { - console.log('Wrong arguments number: ' + args.length + '/3') - process.exit(-1) + throw new Error('Wrong arguments number: ' + args.length + '/3') } var host = args[1] -- cgit v1.2.3