返回提交历史
Modified
src/index.ts
+6
-1
Modified
src/services/configWatcherService.ts
+1
-1
XFEstudio/SpaceNinjaServer
chore: improve error reporting when config.json exists with invalid json (#2166)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2166 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
c6dd8bfb
代码差异
2 个文件
+7
-2
@@ -1,9 +1,14 @@
1
1
// First, init config.
2
2
import { config, loadConfig } from "@/src/services/configService";
3
import fs from "fs";
3
4
try {
4
5
loadConfig();
5
6
} catch (e) {
6
console.log("ERROR: Failed to load config.json. You can copy config.json.example to create your config.json.");
7
if (fs.existsSync("config.json")) {
8
console.log("Failed to load config.json: " + (e as Error).message);
9
} else {
10
console.log("Failed to load config.json. You can copy config.json.example to create your config.json.");
11
}
7
12
process.exit(1);
8
13
}
9
14
@@ -13,7 +13,7 @@ fs.watchFile(configPath, () => {
13
13
try {
14
14
loadConfig();
15
15
} catch (e) {
16
logger.error("Failed to reload config.json. Did you delete it?! Execution cannot continue.");
16
logger.error("FATAL ERROR: Config failed to be reloaded: " + (e as Error).message);
17
17
process.exit(1);
18
18
}
19
19
validateConfig();