UNPKG

1.14 kBTypeScriptView Raw
1interface ErrorOptions {
2 cause?: unknown;
3}
4export declare class CustomError extends Error {
5 name: string;
6 constructor(message?: string, options?: ErrorOptions);
7}
8export {};
9export interface CustomErrorInterface extends Error {
10}
11export interface CustomErrorProperties {
12 [property: string]: any;
13}
14export interface CustomErrorConstructor<Properties extends CustomErrorProperties> extends ErrorConstructor {
15 readonly prototype: CustomErrorInterface;
16 new (...args: any[]): CustomErrorInterface & Properties;
17 (...args: any[]): CustomErrorInterface & Properties;
18}
19export declare type GenericErrorConstructor = ErrorConstructor | EvalErrorConstructor | RangeErrorConstructor | ReferenceErrorConstructor | SyntaxErrorConstructor | TypeErrorConstructor | URIErrorConstructor | CustomErrorConstructor<CustomErrorProperties>;
20declare type CustomErrorFunction<Properties> = (this: Properties, ...args: any[]) => void;
21export declare function customErrorFactory<Properties extends CustomErrorProperties>(fn: CustomErrorFunction<Properties>, parent?: GenericErrorConstructor): CustomErrorConstructor<Properties>;
22export {};