Skip to content

Commit

Permalink
fix: improve error handling when a config file is invalid json (#11)
Browse files Browse the repository at this point in the history
It still isn't great, but it says the file that's wrong and the fact that it was
invalid JSON.
  • Loading branch information
alangpierce authored Sep 3, 2016
1 parent 430c10a commit 81c3467
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/config/resolveConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ export default async function resolveConfig(commander) {
if (filename.startsWith('bulk-decaffeinate')
&& filename.endsWith('.json')
&& !(await stat(filename)).isDirectory()) {
let newConfig = JSON.parse(await readFile(filename));
config = Object.assign(config, newConfig);
try {
let newConfig = JSON.parse(await readFile(filename));
config = Object.assign(config, newConfig);
} catch (e) {
throw new CLIError(
`Error reading file ${filename}. Make sure it is a valid JSON file.`);
}
}
}
config = Object.assign(config, getCLIParamsConfig(commander));
Expand Down

0 comments on commit 81c3467

Please sign in to comment.