feat(onebot11): Improve error handling in JSON parsing

发生错误直接被 catch 掉了,没有提示,[使用docker启动后,请求被重置](https://github.com/NapNeko/NapCat-Docker/issues/8)
This commit is contained in:
风宝宝 2024-04-23 21:33:09 +08:00 committed by GitHub
parent 1df3e9c414
commit c40170db5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,6 +67,11 @@ class Config implements OB11Config {
Object.assign(this, jsonData);
// eslint-disable-next-line
} catch (e) {
if (e instanceof SyntaxError) {
console.error(`配置文件 ${ob11ConfigPath} 格式错误,请检查配置文件:`, e.message);
}else{
console.error(`读取配置文件 ${ob11ConfigPath} 时发生错误:`, e.message);
}
}
return this;
}