Skip to content

Commit b8bdcef

Browse files
committed
fix: assert that Error.prepareStackTrace is not undefined
1 parent b675b23 commit b8bdcef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

v-next/hardhat/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from "./solidity-stack-trace.js";
66

77
import { ReturnData } from "@ignored/edr-optimism";
8+
import { assertHardhatInvariant } from "@ignored/hardhat-vnext-errors";
89
import { bytesToHexString } from "@ignored/hardhat-vnext-utils/bytes";
910

1011
import { panicErrorCodeToMessage } from "./panic-errors.js";
@@ -37,10 +38,12 @@ export function createSolidityErrorWithStackTrace(
3738
}
3839
}
3940

40-
return originalPrepareStackTrace !== undefined
41-
? originalPrepareStackTrace(error, adjustedStack)
42-
: // This should never happen, but just in case we add a fallback
43-
`Error: ${error.message}\n at ${adjustedStack.join("\n at ")}`;
41+
assertHardhatInvariant(
42+
originalPrepareStackTrace !== undefined,
43+
"Error.prepareStackTrace should be defined",
44+
);
45+
46+
return originalPrepareStackTrace(error, adjustedStack);
4447
};
4548

4649
const message =

0 commit comments

Comments
 (0)