import type { ErrorDescriptor } from "./descriptors.js"; import { CustomError } from "@nomicfoundation/hardhat-utils/error"; import { ERRORS } from "./descriptors.js"; export type ErrorMessageTemplateValue = string | number | boolean | bigint | undefined | null | ErrorMessageTemplateValue[] | { toString(): string; }; export type MessageTemplateArguments = MessageTemplateT extends `${string}{${infer Tag}}${infer Rest}` ? { [K in Tag | keyof MessageTemplateArguments]: ErrorMessageTemplateValue; } : {}; export type HardhatErrorConstructorArguments = keyof MessageTemplateArguments extends never ? [ErrorDescriptorT, Error?] : [ ErrorDescriptorT, MessageTemplateArguments, Error? ]; export declare const ERROR_PREFIX = "HHE"; /** * An error thrown by Hardhat. This error is meant to be thrown by Hardhat * itself, and internal plugins. For errors thrown by community plugins, see * `HardhatPluginError`. */ export declare class HardhatError extends CustomError { #private; static readonly ERRORS: typeof ERRORS; constructor(...[errorDescriptor, messageArgumentsOrParentError, parentError,]: HardhatErrorConstructorArguments); static isHardhatError(other: unknown): other is HardhatError; static isHardhatError(other: unknown, descriptor?: ErrorDescriptorT): other is HardhatError; get number(): number; get pluginId(): string | undefined; get descriptor(): ErrorDescriptor; get messageArguments(): MessageTemplateArguments; get errorCode(): string; get formattedMessage(): string; } /** * An error thrown by a Hardhat plugin. This error is meant to be thrown by * community plugins to signal that something went wrong. */ export declare class HardhatPluginError extends CustomError { readonly pluginId: string; constructor(pluginId: string, message: string, parentError?: Error); static isHardhatPluginError(other: unknown): other is HardhatPluginError; } /** * Asserts an internal invariant. * * @param invariant The condition to check. * @param message A message to show if the condition is false. */ export declare function assertHardhatInvariant(invariant: boolean, message: string): asserts invariant; /** * This function applies error messages templates like this: * * - Template is a string which contains a variable tags. A variable tag is a * a variable name surrounded by %. Eg: %plugin1% * - A variable name is a string of alphanumeric ascii characters. * - Every variable tag is replaced by its value. * - %% is replaced by %. * - Values can't contain variable tags. * - If a variable is not present in the template, but present in the values * object, an error is thrown. * * @param template The template string. * @param values A map of variable names to their values. */ export declare function applyErrorMessageTemplate(template: string, values: Record): string; //# sourceMappingURL=errors.d.ts.map