UNPKG

@fairmint/canton-node-sdk

Version:
37 lines 1.49 kB
import { z } from 'zod'; /** Utility functions for consistent WebSocket error handling */ export declare class WebSocketErrorUtils { /** * Safely parses a message using multiple schemas, throwing descriptive errors if all fail * * @param msg - The message to parse * @param schemas - Array of schemas to try in order * @param operationName - Name of the operation for error context * @returns The parsed message * @throws CantonError if all schemas fail to parse */ static parseWithFallback<T>(msg: unknown, schemas: Array<{ schema: z.ZodSchema<T>; name: string; }>, operationName: string): T; /** * Parses a union schema and returns the result without type assertion * * @param msg - The message to parse * @param unionSchema - The Zod union schema * @param operationName - Name of the operation for error context * @returns The parsed message with proper typing * @throws CantonError if parsing fails */ static parseUnion<T>(msg: unknown, unionSchema: z.ZodSchema<T>, operationName: string): T; /** * Creates a safe JSON parser that throws descriptive errors * * @param data - Raw data to parse * @param context - Context for error messages * @returns Parsed JSON object * @throws CantonError if JSON parsing fails */ static safeJsonParse(data: string, context: string): unknown; } //# sourceMappingURL=WebSocketErrorUtils.d.ts.map