chore: improve error reporting when config.json exists with invalid json #2166

Merged
Sainan merged 1 commits from config-error into main 2025-06-15 18:51:32 -07:00
2 changed files with 7 additions and 2 deletions

View File

@ -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);
} }

View File

@ -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();