@nomicfoundation/hardhat-chai-matchers
Version:
Hardhat utils for testing
16 lines (13 loc) • 347 B
text/typescript
/* eslint-disable @typescript-eslint/prefer-function-type */
interface ErrorConstructor<T extends any[]> {
new (...args: T): Error;
}
export function ensure<T extends any[]>(
condition: boolean,
ErrorToThrow: ErrorConstructor<T>,
...errorArgs: T
): asserts condition {
if (!condition) {
throw new ErrorToThrow(...errorArgs);
}
}