UNPKG

collectlie

Version:

TypeScript SDK for Collectlie - flexible data collection platform with custom types, schema validation, and Supabase backend integration

87 lines 3.13 kB
/** * Custom error types for Collectlie SDK * These errors preserve all details from backend responses */ /** * Base error class for all Collectlie errors * Preserves backend error structure and adds helpful context */ export declare class CollectlieError extends Error { /** HTTP status code from the response */ readonly status: number; /** Error code for programmatic handling */ readonly code: string; /** Additional error details from backend */ readonly details?: string | string[]; /** Debug information from backend (development mode) */ readonly debugInfo?: Record<string, any>; /** Whether the error requires a plan upgrade */ readonly upgradeRequired?: boolean; constructor(message: string, status: number, code: string, details?: string | string[], debugInfo?: Record<string, any>, upgradeRequired?: boolean); /** * Get a formatted error message with all details */ toDetailedString(): string; } /** * Validation error (HTTP 400) * Thrown when request data fails validation */ export declare class ValidationError extends CollectlieError { constructor(message: string, details?: string | string[], debugInfo?: Record<string, any>); } /** * Authentication/Authorization error (HTTP 403) * Thrown for API key issues, domain restrictions, or permission errors */ export declare class AuthenticationError extends CollectlieError { constructor(message: string, details?: string | string[], debugInfo?: Record<string, any>, upgradeRequired?: boolean); } /** * Payload too large error (HTTP 413) * Thrown when request exceeds size limits */ export declare class PayloadTooLargeError extends CollectlieError { constructor(message: string, details?: string | string[], debugInfo?: Record<string, any>); } /** * Rate limit error (HTTP 429) * Thrown when rate limits are exceeded */ export declare class RateLimitError extends CollectlieError { /** When the rate limit resets (if provided by backend) */ readonly resetAt?: Date; constructor(message: string, details?: string | string[], debugInfo?: Record<string, any>, resetAt?: string); } /** * Server error (HTTP 500+) * Thrown for internal server errors */ export declare class ServerError extends CollectlieError { constructor(message: string, status?: number, details?: string | string[], debugInfo?: Record<string, any>); } /** * Network error * Thrown for connection issues, timeouts, etc. */ export declare class NetworkError extends CollectlieError { constructor(message: string, originalError?: Error); } /** * Configuration error * Thrown for SDK configuration issues */ export declare class ConfigurationError extends CollectlieError { constructor(message: string, details?: string | string[]); } /** * Create appropriate error based on HTTP status and response */ export declare function createErrorFromResponse(status: number, errorData: { error?: string; message?: string; details?: string | string[]; debug_info?: Record<string, any>; upgrade_required?: boolean; }): CollectlieError; //# sourceMappingURL=errors.d.ts.map