@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
40 lines • 1.25 kB
TypeScript
/**
* Error Handler
* Decides how to handle errors - display to user, mark as handled, or throw
*/
import { SwapError } from "./SwapError";
/**
* Interface for error handler options
*/
export interface ErrorHandlerOptions {
/**
* Callback to display error to user (optional)
* If not provided, errors are simply thrown
*/
onDisplayError?: (error: SwapError) => Promise<void>;
/**
* Additional error names to ignore (won't be displayed)
*/
ignoredErrorNames?: string[];
/**
* Additional error messages to ignore (won't be displayed)
*/
ignoredMessages?: string[];
}
/**
* Handles errors by deciding whether to display them or mark as handled
*
* @param error - The error to handle
* @param options - Configuration options
* @throws Enhanced error with `handled` flag if applicable
*/
export declare function handleErrors(error: unknown, options?: ErrorHandlerOptions): Promise<void>;
/**
* Type guard to check if an error is marked as handled
*/
export declare function isHandledError(error: unknown): boolean;
/**
* Extracts swap code from error if available
*/
export declare function getSwapCode(error: unknown): string | undefined;
//# sourceMappingURL=handleSwapErrors.d.ts.map