@visulima/error
Version:
Error with more than just a message, stacktrace parsing.
26 lines (25 loc) • 926 B
TypeScript
type ErrorConstructor = new (...arguments_: any[]) => Error;
/**
* Add a known error constructor to the registry.
* @param constructor The error constructor to add
* @param name Optional custom name to use instead of instance.name
* @throws {Error} If the constructor is already known or incompatible
*/
export declare const addKnownErrorConstructor: (constructor: ErrorConstructor, name?: string) => void;
/**
* Get all known error constructors.
*/
export declare const getKnownErrorConstructors: () => Map<string, new (...arguments_: any[]) => Error>;
/**
* Get a specific error constructor by name.
*/
export declare const getErrorConstructor: (name: string) => (new (...arguments_: any[]) => Error) | undefined;
/**
* Check if an object looks like a serialized error.
*/
export declare const isErrorLike: (value: unknown) => value is {
message?: string;
name?: string;
stack?: string;
};
export {};