Log errors in faulty custom config file

CryptPAD now terminates and does not fallback to default config if the custom config is faulty.
The error in the custom config is logged to the terminal now.

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
Adrian Nöthlich 2020-01-04 23:58:01 +01:00
parent 89d9f22e0e
commit a714e41d49
No known key found for this signature in database
GPG key ID: CBA6B4E35D326EFE

View file

@ -8,7 +8,14 @@ try {
console.log("You can configure the administrator email (adminEmail) in your config/config.js file");
}
} catch (e) {
console.log("Config not found, loading the example config. You can customize the configuration by copying config/config.example.js to " + configPath);
if (e instanceof SyntaxError) {
console.error("config/config.js is faulty. See stacktrace below for more information. Terminating. \n");
console.error(e.name + ": " + e.message);
console.error(e.stack.split("\n\n")[0]);
process.exit(1);
} else {
console.log("Config not found, loading the example config. You can customize the configuration by copying config/config.example.js to " + configPath);
}
config = require("../config/config.example");
}
module.exports = config;