Skip to content

Commit

Permalink
fix: Fix unhandled promise rejections and improve error context Updat…
Browse files Browse the repository at this point in the history
…e async-test-sanity.js
  • Loading branch information
ursulabauer authored Jan 12, 2025
1 parent 96b40d0 commit c3156f6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hardhat/async-test-sanity.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
process.on('unhandledRejection', reason => {
throw new Error(reason);
// If the reason is already an Error object, throw it directly to preserve the stack trace.
if (reason instanceof Error) {
throw reason;
} else {
// If the reason is not an Error (e.g., a string, number, or other primitive),
// create a new Error object with the reason as its message.
throw new Error(`Unhandled rejection: ${reason}`);
}
});

0 comments on commit c3156f6

Please sign in to comment.