@lodestar/utils
Version:
Utilities required across multiple lodestar packages
46 lines • 1.37 kB
TypeScript
export type LodestarErrorMetaData = Record<string, string | number | null>;
export type LodestarErrorObject = {
message: string;
stack: string;
className: string;
type: LodestarErrorMetaData;
};
export type FromObjectFn = (object: LodestarErrorObject) => Error;
/**
* Generic Lodestar error with attached metadata
*/
export declare class LodestarError<T extends {
code: string;
}> extends Error {
type: T;
constructor(type: T, message?: string, stack?: string);
getMetadata(): LodestarErrorMetaData;
/**
* Get the metadata and the stacktrace for the error.
*/
toObject(): LodestarErrorObject;
static fromObject(obj: LodestarErrorObject): LodestarError<{
code: string;
}>;
}
/**
* Throw this error when an upstream abort signal aborts
*/
export declare class ErrorAborted extends Error {
constructor(message?: string);
}
/**
* Throw this error when wrapped timeout expires
*/
export declare class TimeoutError extends Error {
constructor(message?: string);
}
/**
* Returns true if arg `e` is an instance of `ErrorAborted`
*/
export declare function isErrorAborted(e: unknown): e is ErrorAborted;
/**
* Extend an existing error by appending a string to its `e.message`
*/
export declare function extendError(e: Error, appendMessage: string): Error;
//# sourceMappingURL=errors.d.ts.map