nicer error for syntax errors in config.yaml
Massimo Melina committed
Jun 20, 2024 at 23:33 UTC
5d300a74905a49b36496eb7f8d220bf33e27591c
1 file changed
+4
-1
src/config.ts
+4
-1
@@ -183,7 +183,10 @@ function stringify(obj: any) {
183
}
184
185
console.log("config", filePath)
186
-export const configFile = watchLoad(filePath, text => setConfig(yaml.parse(text, { uniqueKeys: false })||{}, false), {
186
+export const configFile = watchLoad(filePath, text => {
187
+ try { setConfig(yaml.parse(text, { uniqueKeys: false }) || {}, false) }
188
+ catch(e: any) { console.error("Error in", filePath, ':', e.message || String(e)) }
189
+}, {
190
failedOnFirstAttempt(){
191
console.log("No config file, using defaults")
192
setConfig({}, false)