From 62afcaadaba9c61511902b234005687b31a2afd5 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 9 Dec 2019 17:51:38 +0100 Subject: [PATCH] Use shared StartupError class Remove separate StartupError class definition in master.js in favor of the shared StartupError class in lib/error.js. --- master.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/master.js b/master.js index b6978d97..c47930e8 100644 --- a/master.js +++ b/master.js @@ -542,9 +542,6 @@ async function getPlugins(){ return plugins; } -// Errror class for known errors occuring during startup -class StartupError extends Error { } - /** * Calls listen on server capturing any errors that occurs * binding to the port. @@ -552,7 +549,7 @@ class StartupError extends Error { } function listen(server, ...args) { return new Promise((resolve, reject) => { function wrapError(err) { - reject(new StartupError( + reject(new errors.StartupError( `Server listening failed: ${err.message}` )); } @@ -640,7 +637,7 @@ async function startServer() { privateKey = await fs.readFile(config.sslPrivKey); } catch (err) { - throw new StartupError( + throw new errors.StartupError( `Error loading ssl certificate: ${err.message}` ); } @@ -680,19 +677,19 @@ I version of clusterio. Expect things to break. I ` ); startServer().catch(err => { - if (!(err instanceof StartupError)) { + if (err instanceof errors.StartupError) { + console.error(` ++----------------------------------+ +| Unable to to start master server | ++----------------------------------+` + ); + } else { console.error(` +---------------------------------------------------------------+ | Unexpected error occured while starting master, please report | | it to https://github.com/clusterio/factorioClusterio/issues | +---------------------------------------------------------------+` ); - } else { - console.error(` -+----------------------------------+ -| Unable to to start master server | -+----------------------------------+` - ); } console.error(err);