Settings.js: exit gracefully if an invalid credentials.json is passed.
Before this commit, when passed a malformed credentials.json the application crashed with a stack dump. Now we catch the error and fail in a controlled way (like already done for settings.json). Example of exception we no longer throw: MALFORMEDJSON ^ SyntaxError: Unexpected token M in JSON at position 0 at JSON.parse (<anonymous>) at Object.reloadSettings (<BASEDIR>/src/node/utils/Settings.js:390:24) at Object.<anonymous> (<BASEDIR>/src/node/utils/Settings.js:543:9) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18)pull/3573/head
parent
8fa52659f5
commit
ab57edef33
|
@ -379,10 +379,15 @@ exports.reloadSettings = function reloadSettings() {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
if (credentialsStr) {
|
if (credentialsStr) {
|
||||||
credentialsStr = jsonminify(credentialsStr).replace(",]","]").replace(",}","}");
|
credentialsStr = jsonminify(credentialsStr).replace(",]","]").replace(",}","}");
|
||||||
credentials = JSON.parse(credentialsStr);
|
credentials = JSON.parse(credentialsStr);
|
||||||
}
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.error(`There was an error processing your credentials file from ${credentialsFilename}:` + e.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
//loop trough the settings
|
//loop trough the settings
|
||||||
for (var i in settings) {
|
for (var i in settings) {
|
||||||
|
|
Loading…
Reference in New Issue