UNPKG

taglib-wasm

Version:

TagLib for TypeScript platforms: Deno, Node.js, Bun, Electron, browsers, and Cloudflare Workers

93 lines 3.75 kB
/** * Custom error types for taglib-wasm with enhanced context and debugging information */ /** * List of audio formats supported by taglib-wasm */ export declare const SUPPORTED_FORMATS: readonly ["MP3", "MP4", "M4A", "FLAC", "OGG", "WAV"]; /** * Error codes for programmatic error handling */ export type TagLibErrorCode = "INITIALIZATION_FAILED" | "INVALID_FORMAT" | "UNSUPPORTED_FORMAT" | "FILE_OPERATION_FAILED" | "METADATA_ERROR" | "MEMORY_ERROR" | "ENVIRONMENT_ERROR"; /** * Base error class for all taglib-wasm errors */ export declare class TagLibError extends Error { readonly code: string; readonly details?: Record<string, any> | undefined; constructor(code: string, message: string, details?: Record<string, any> | undefined); } /** * Error thrown when the Wasm module fails to initialize */ export declare class TagLibInitializationError extends TagLibError { constructor(message: string, details?: Record<string, any>); } /** * Error thrown when an audio file format is invalid or corrupted */ export declare class InvalidFormatError extends TagLibError { readonly bufferSize?: number | undefined; constructor(message: string, bufferSize?: number | undefined, details?: Record<string, any>); } /** * Error thrown when an audio format is recognized but not supported */ export declare class UnsupportedFormatError extends TagLibError { readonly format: string; readonly supportedFormats: readonly string[]; constructor(format: string, supportedFormats?: readonly string[], details?: Record<string, any>); } /** * Error thrown during file operations (read, write, save) */ export declare class FileOperationError extends TagLibError { readonly operation: "read" | "write" | "save" | "stat"; readonly path?: string | undefined; constructor(operation: "read" | "write" | "save" | "stat", message: string, path?: string | undefined, details?: Record<string, any>); } /** * Error thrown when metadata operations fail */ export declare class MetadataError extends TagLibError { readonly operation: "read" | "write"; readonly field?: string | undefined; constructor(operation: "read" | "write", message: string, field?: string | undefined, details?: Record<string, any>); } /** * Error thrown when Wasm memory operations fail */ export declare class MemoryError extends TagLibError { constructor(message: string, details?: Record<string, any>); } /** * Error thrown when the environment doesn't support required features */ export declare class EnvironmentError extends TagLibError { readonly environment: string; readonly reason: string; readonly requiredFeature?: string | undefined; constructor(environment: string, reason: string, requiredFeature?: string | undefined); } /** * Error thrown when worker pool operations fail * * @example * ```typescript * throw new WorkerError("Worker initialization timed out"); * ``` */ export declare class WorkerError extends TagLibError { constructor(message: string, details?: Record<string, any>); } /** * Type guards for error handling */ export declare function isTagLibError(error: unknown): error is TagLibError; export declare function isInvalidFormatError(error: unknown): error is InvalidFormatError; export declare function isUnsupportedFormatError(error: unknown): error is UnsupportedFormatError; export declare function isFileOperationError(error: unknown): error is FileOperationError; export declare function isMetadataError(error: unknown): error is MetadataError; export declare function isMemoryError(error: unknown): error is MemoryError; export declare function isEnvironmentError(error: unknown): error is EnvironmentError; //# sourceMappingURL=errors.d.ts.map