export type HelpfulErrorMetadata = Record & { cause?: Error; }; /** * HelpfulError errors are used to add information that helps the future observer of the error understand whats going on */ export declare class HelpfulError extends Error { constructor(message: string, metadata?: HelpfulErrorMetadata); /** * a utility to throw an error of this class, for convenience * * e.g., * ```ts * const phone = customer.phone ?? HelpfulError.throw('expected a phone'); * ``` */ static throw(this: T, // https://stackoverflow.com/a/51749145/3068233 message: string, metadata?: HelpfulErrorMetadata): never; /** * an override to ensure that errors are serialized to json expressively * * ref * - https://stackoverflow.com/a/18391400/3068233 * - https://github.com/nodejs/node/issues/29090 */ toJSON(this: T, // https://stackoverflow.com/a/51749145/3068233 message: string, metadata?: HelpfulErrorMetadata): Record; }