mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Use shared StartupError class
Remove separate StartupError class definition in master.js in favor of the shared StartupError class in lib/error.js.
This commit is contained in:
1 parent
b59fd80a7b
commit
62afcaadab
1 file changed
+9
-12
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user