unified-error-handling
Version:
A lightweight, zero-dependency error handling library with dynamic adapter loading for multiple error tracking services
52 lines • 2.49 kB
TypeScript
import type { ErrorStore, ErrorStoreConfig, ErrorContext, UserContext, Breadcrumb, NormalizedError, ErrorAdapter, ErrorListener } from './types';
declare class ErrorStoreImpl implements ErrorStore {
context: ErrorContext;
breadcrumbs: Breadcrumb[];
adapters: Map<string, ErrorAdapter>;
activeAdapter: string | null;
config: ErrorStoreConfig;
initialized: boolean;
offline: boolean;
errorQueue: NormalizedError[];
private listeners;
private globalHandlersInstalled;
private offlineHandler?;
private onlineHandler?;
constructor();
initialize(config?: ErrorStoreConfig): void;
captureError(error: Error | string, additionalContext?: Partial<ErrorContext>): void;
captureMessage(message: string, level?: string): void;
setUser(user: UserContext | null): void;
setContext(context: Partial<ErrorContext>): void;
addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void;
clearBreadcrumbs(): void;
useAdapter(name: string, config?: any): Promise<void>;
removeAdapter(name: string): void;
flush(): Promise<void>;
reset(): void;
subscribe(listener: ErrorListener): () => void;
registerAdapter(name: string, adapter: ErrorAdapter): void;
private normalizeError;
private sendToAdapter;
private installGlobalHandlers;
private removeGlobalHandlers;
private setupOfflineHandlers;
private processOfflineQueue;
private loadBuiltInAdapter;
}
export declare const errorStore: ErrorStoreImpl;
export declare const initialize: (config?: ErrorStoreConfig) => void;
export declare const captureError: (error: Error | string, additionalContext?: Partial<ErrorContext>) => void;
export declare const captureMessage: (message: string, level?: string) => void;
export declare const setUser: (user: UserContext | null) => void;
export declare const setContext: (context: Partial<ErrorContext>) => void;
export declare const addBreadcrumb: (breadcrumb: Omit<Breadcrumb, "timestamp">) => void;
export declare const clearBreadcrumbs: () => void;
export declare const useAdapter: (name: string, config?: any) => Promise<void>;
export declare const removeAdapter: (name: string) => void;
export declare const flush: () => Promise<void>;
export declare const reset: () => void;
export declare const subscribe: (listener: ErrorListener) => () => void;
export declare const registerAdapter: (name: string, adapter: ErrorAdapter) => void;
export {};
//# sourceMappingURL=error-store.d.ts.map