UNPKG

taglib-wasm

Version:

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

89 lines 3.69 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 declare enum TagLibErrorCode { INITIALIZATION_FAILED = "INITIALIZATION_FAILED", INVALID_FORMAT = "INVALID_FORMAT", UNSUPPORTED_FORMAT = "UNSUPPORTED_FORMAT", FILE_OPERATION_FAILED = "FILE_OPERATION_FAILED", METADATA_ERROR = "METADATA_ERROR", MEMORY_ERROR = "MEMORY_ERROR", ENVIRONMENT_ERROR = "ENVIRONMENT_ERROR" } /** * Base error class for all taglib-wasm errors */ export declare class TagLibError extends Error { readonly code: TagLibErrorCode; readonly context?: Record<string, unknown> | undefined; constructor(message: string, code: TagLibErrorCode, context?: Record<string, unknown> | undefined); } /** * Error thrown when the Wasm module fails to initialize */ export declare class TagLibInitializationError extends TagLibError { constructor(message: string, context?: Record<string, unknown>); } /** * 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, context?: Record<string, unknown>); } /** * 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[], context?: Record<string, unknown>); } /** * 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, context?: Record<string, unknown>); } /** * 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, context?: Record<string, unknown>); } /** * Error thrown when Wasm memory operations fail */ export declare class MemoryError extends TagLibError { constructor(message: string, context?: Record<string, unknown>); } /** * Error thrown when the environment doesn't support required features */ export declare class EnvironmentError extends TagLibError { readonly environment: string; readonly requiredFeature?: string | undefined; constructor(environment: string, message: string, requiredFeature?: string | undefined, context?: Record<string, unknown>); } /** * 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