@remcostoeten/fync
Version:
A unified TypeScript library for easy access to popular APIs (GitHub, Spotify, GitLab, etc.)
42 lines • 1.24 kB
TypeScript
import type { TErrorInfo, TErrorHandler, TErrorTransformer, TRecoveryStrategy, TErrorContext } from "./types";
/**
* Base class for all errors
*/
export declare class BaseError extends Error {
info: TErrorInfo;
constructor(info: TErrorInfo);
}
/**
* Centralized error utility class for building and managing errors
*/
export declare class ErrorUtil {
private static transformers;
private static handlers;
private static recoveries;
private static initialized;
/**
* Register error transformer
*/
static registerTransformer(transformer: TErrorTransformer): void;
/**
* Register error handler
*/
static registerHandler(handler: TErrorHandler): void;
/**
* Register recovery strategy
*/
static registerRecovery(recovery: TRecoveryStrategy): void;
/**
* Generate a BaseError from unknown error
*/
static createError(error: unknown, context: Partial<TErrorContext>): BaseError;
/**
* Handle the provided error
*/
static handle(error: BaseError): Promise<void>;
/**
* Attempt to recover from an error
*/
static recover<T = unknown>(error: BaseError): Promise<T | null>;
}
//# sourceMappingURL=index.d.ts.map