More precise error message to DirWatch when failing to import from trunk-recorder

This commit is contained in:
Chrystian Huot 2020-06-03 15:42:14 -04:00
parent dd8e5d16aa
commit ba025dc1e4

View file

@ -132,9 +132,18 @@ class DirWatch {
const system = this.parseRegex(dirWatch.system, filename); const system = this.parseRegex(dirWatch.system, filename);
try { let meta;
const meta = JSON.parse(this.readFile(filename, 'utf8'));
try {
meta = JSON.parse(this.readFile(filename, 'utf8'));
} catch (error) {
console.error(`DirWatch: Error parsing json file ${filename}`);
return;
}
try {
await this.app.controller.importTrunkRecorder(audio, audioName, audioType, system, meta); await this.app.controller.importTrunkRecorder(audio, audioName, audioType, system, meta);
if (dirWatch.deleteAfter) { if (dirWatch.deleteAfter) {
@ -144,10 +153,15 @@ class DirWatch {
} }
} catch (error) { } catch (error) {
console.error(`DirWatch: Error loading file ${filename}`); console.error(`DirWatch: Error importing file ${audioFile}`);
return; return;
} }
} else {
console.error(`DirWatch: Error missing file ${audioFile}`);
return;
} }
} }
} }