chore: improve error reporting when config.json exists with invalid json
This commit is contained in:
parent
12d09531b3
commit
96bbc92ae9
@ -1,9 +1,14 @@
|
|||||||
// First, init config.
|
// First, init config.
|
||||||
import { config, loadConfig } from "@/src/services/configService";
|
import { config, loadConfig } from "@/src/services/configService";
|
||||||
|
import fs from "fs";
|
||||||
try {
|
try {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("ERROR: Failed to load config.json. You can copy config.json.example to create your config.json.");
|
if (fs.existsSync("config.json")) {
|
||||||
|
console.log("Failed to load config.json: " + (e as Error).message);
|
||||||
|
} else {
|
||||||
|
console.log("Failed to load config.json. You can copy config.json.example to create your config.json.");
|
||||||
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ fs.watchFile(configPath, () => {
|
|||||||
try {
|
try {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("Failed to reload config.json. Did you delete it?! Execution cannot continue.");
|
logger.error("FATAL ERROR: Config failed to be reloaded: " + (e as Error).message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
validateConfig();
|
validateConfig();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user