bigblocks
Version:
Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React
51 lines • 1.89 kB
TypeScript
import type { SocialError, SocialErrorCode } from "../components/social/types/social.js";
/**
* Standardized API Error class that implements SocialError interface
* while extending native Error for proper stack traces and instanceof checks
*/
export declare class ApiError extends Error implements SocialError {
readonly code: SocialErrorCode;
readonly details?: Error | Record<string, unknown>;
constructor(code: SocialErrorCode, message: string, details?: Error | Record<string, unknown>);
/**
* Convert a generic error to an ApiError
*/
static fromError(error: unknown, code?: SocialErrorCode): ApiError;
/**
* Create a network error for fetch failures
*/
static networkError(message: string, details?: Record<string, unknown>): ApiError;
/**
* Create an unauthorized error
*/
static unauthorized(message?: string): ApiError;
/**
* Create a transaction failed error
*/
static transactionFailed(message: string, details?: Record<string, unknown>): ApiError;
/**
* Create a broadcast failed error
*/
static broadcastFailed(message: string, details?: Record<string, unknown>): ApiError;
/**
* Check if an error is an API error with a specific code
*/
static isApiError(error: unknown, code?: SocialErrorCode): error is ApiError;
/**
* Serialize the error for logging or transmission
*/
toJSON(): Record<string, unknown>;
/**
* Convert to SocialError interface (for compatibility)
*/
toSocialError(): SocialError;
}
/**
* Type guard to check if an error implements SocialError interface
*/
export declare function isSocialError(error: unknown): error is SocialError;
/**
* Convert any error to a standardized SocialError
*/
export declare function toSocialError(error: unknown): SocialError;
//# sourceMappingURL=api-error.d.ts.map