Skip to content

Commit 7e01acf

Browse files
committed
cleaner error message; fixes #69
1 parent 13c64c0 commit 7e01acf

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bin/query.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@ export default async function run(args?: string[]): Promise<void> {
4545
else strings.push(positionals[i]);
4646
}
4747

48-
process.chdir(values.root);
49-
const cachePath = await getQueryCachePath(".", values.database, strings, ...params);
50-
const config = await getDatabaseConfig(".", values.database);
51-
const database = await getDatabase(config);
52-
const results = await database.call(null, strings, ...params);
53-
await mkdir(dirname(cachePath), {recursive: true});
54-
await writeFile(cachePath, JSON.stringify(results, replace));
55-
console.log(join(values.root, cachePath));
48+
try {
49+
process.chdir(values.root);
50+
const cachePath = await getQueryCachePath(".", values.database, strings, ...params);
51+
const config = await getDatabaseConfig(".", values.database);
52+
const database = await getDatabase(config);
53+
const results = await database.call(null, strings, ...params);
54+
await mkdir(dirname(cachePath), {recursive: true});
55+
await writeFile(cachePath, JSON.stringify(results, replace));
56+
console.log(join(values.root, cachePath));
57+
} catch (error) {
58+
console.error(String(error));
59+
process.exit(1);
60+
}
5661
}
5762

5863
// Force dates to be serialized as ISO 8601 UTC, undoing this:

0 commit comments

Comments
 (0)