Skip to content

Commit

Permalink
Improve promise rejections handling in hardhat/async-test-sanity.js (#…
Browse files Browse the repository at this point in the history
…5429)

Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com>
  • Loading branch information
ursulabauer and arr00 authored Feb 4, 2025
1 parent 19c2f2f commit b9dbfa7
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 b9dbfa7

Please sign in to comment.