Grafana-Toolkit: Improve error messages when tasks fail (#36381)

This commit is contained in:
Josh Hunt 2021-07-06 10:07:17 +01:00 committed by GitHub
parent d87e086d6f
commit 227c11d37f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,9 +6,15 @@ export const useSpinner = async (label: string, fn: () => Promise<any>, killProc
try {
await fn();
spinner.succeed();
} catch (e) {
console.trace(e); // eslint-disable-line no-console
spinner.fail(e.message || e);
} catch (err) {
spinner.fail(err.message || err);
if (err.stdout) {
console.error(err.stdout);
} else {
console.trace(err); // eslint-disable-line no-console
}
if (killProcess) {
process.exit(1);
}