chore: improve error reporting when config.json exists with invalid json
All checks were successful
Build / build (push) Successful in 46s
Build / build (pull_request) Successful in 1m3s

This commit is contained in:
Sainan 2025-06-15 12:57:36 +02:00
parent 12d09531b3
commit 96bbc92ae9
2 changed files with 7 additions and 2 deletions

View File

@ -1,9 +1,14 @@
// First, init config.
import { config, loadConfig } from "@/src/services/configService";
import fs from "fs";
try {
loadConfig();
} 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);
}

View File

@ -13,7 +13,7 @@ fs.watchFile(configPath, () => {
try {
loadConfig();
} 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);
}
validateConfig();