Skip to content

Commit

Permalink
fix: improve error reporting (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Apr 23, 2024
1 parent 06a242b commit ac563c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/perf-insight/src/runBenchmarkCli.mts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ async function run(args: string[]) {
const url = new URL(file, cwdUrl).toString();
try {
await import(url);
} catch (_) {
errors.push(new Error(`Failed to import file: ${file}`));
} catch (e) {
const err = new Error(`Failed to import file: ${file}`);
err.cause = e;
errors.push(err);
}
}

Expand All @@ -49,7 +51,7 @@ async function run(args: string[]) {

if (errors.length) {
console.error('Errors:');
errors.forEach((err) => console.error(err.message));
errors.forEach((err) => console.error('- %s\n%o', err.message, err.cause));
process.exitCode = 1;
return;
}
Expand Down

0 comments on commit ac563c4

Please sign in to comment.