aura-glass
Version:
A comprehensive glassmorphism design system for React applications with 142+ production-ready components
76 lines • 2.32 kB
TypeScript
import React from "react";
export interface ErrorInfo {
componentStack: string;
errorBoundary?: string;
timestamp: number;
}
export interface ErrorState {
hasError: boolean;
error: Error | null;
errorInfo: ErrorInfo | null;
errorId: string | null;
retryCount: number;
}
export interface ErrorBoundaryOptions {
maxRetries?: number;
resetOnPropsChange?: boolean;
resetTimeout?: number;
onError?: (error: Error, errorInfo: ErrorInfo) => void;
onReset?: () => void;
fallback?: React.ComponentType<{
error: Error;
errorInfo: ErrorInfo;
retry: () => void;
}>;
}
/**
* Enhanced error boundary hook with retry logic and error reporting
*/
export declare function useErrorBoundary(options?: ErrorBoundaryOptions): {
captureError: (error: Error, errorInfo?: Partial<ErrorInfo>) => void;
resetError: () => void;
retry: () => void;
withErrorBoundary: <P extends object>(Component: React.ComponentType<P>, fallback?: React.ComponentType<{
error: Error;
errorInfo: ErrorInfo;
retry: () => void;
}>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<any>>;
canRetry: boolean;
hasError: boolean;
error: Error | null;
errorInfo: ErrorInfo | null;
errorId: string | null;
retryCount: number;
};
/**
* Hook for async error handling with retry logic
*/
export declare function useAsyncError(): {
error: Error | null;
isRetrying: boolean;
retryCount: number;
captureAsyncError: (error: Error) => void;
retryAsync: (asyncFn: () => Promise<any>, maxRetries?: number) => Promise<any>;
clearError: () => void;
};
/**
* Hook for graceful degradation
*/
export declare function useGracefulDegradation<T>(primaryFeature: () => T, fallbackFeature: () => T, testCondition: () => boolean): T;
/**
* Hook for error reporting and analytics
*/
export declare function useErrorReporting(options?: {
enableReporting?: boolean;
endpoint?: string;
apiKey?: string;
userId?: string;
sessionId?: string;
}): {
reportError: (error: Error, context?: {
component?: string;
action?: string;
metadata?: Record<string, any>;
}) => Promise<void>;
};
//# sourceMappingURL=useErrorBoundary.d.ts.map