/** * @fileoverview Custom error classes for @writenex/astro * * This module provides categorized error types for better error handling, * debugging, and user-facing error messages across the integration. * * ## Error Categories: * - Configuration errors (invalid config, missing files) * - Filesystem errors (read/write failures, permissions) * - Content errors (parsing, validation, not found) * - API errors (request handling, validation) * - Version history errors (manifest, storage) * * @module @writenex/astro/core/errors */ /** * Error codes for categorization and i18n support */ declare enum WritenexErrorCode { CONFIG_NOT_FOUND = "CONFIG_NOT_FOUND", CONFIG_INVALID = "CONFIG_INVALID", CONFIG_PARSE_ERROR = "CONFIG_PARSE_ERROR", FS_READ_ERROR = "FS_READ_ERROR", FS_WRITE_ERROR = "FS_WRITE_ERROR", FS_DELETE_ERROR = "FS_DELETE_ERROR", FS_PERMISSION_DENIED = "FS_PERMISSION_DENIED", FS_PATH_NOT_FOUND = "FS_PATH_NOT_FOUND", FS_PATH_TRAVERSAL = "FS_PATH_TRAVERSAL", CONTENT_NOT_FOUND = "CONTENT_NOT_FOUND", CONTENT_PARSE_ERROR = "CONTENT_PARSE_ERROR", CONTENT_VALIDATION_ERROR = "CONTENT_VALIDATION_ERROR", CONTENT_ALREADY_EXISTS = "CONTENT_ALREADY_EXISTS", CONTENT_INVALID_SLUG = "CONTENT_INVALID_SLUG", CONTENT_CONFLICT = "CONTENT_CONFLICT", COLLECTION_NOT_FOUND = "COLLECTION_NOT_FOUND", COLLECTION_EMPTY = "COLLECTION_EMPTY", COLLECTION_DISCOVERY_ERROR = "COLLECTION_DISCOVERY_ERROR", API_BAD_REQUEST = "API_BAD_REQUEST", API_METHOD_NOT_ALLOWED = "API_METHOD_NOT_ALLOWED", API_INTERNAL_ERROR = "API_INTERNAL_ERROR", API_TIMEOUT = "API_TIMEOUT", IMAGE_INVALID_TYPE = "IMAGE_INVALID_TYPE", IMAGE_TOO_LARGE = "IMAGE_TOO_LARGE", IMAGE_UPLOAD_ERROR = "IMAGE_UPLOAD_ERROR", IMAGE_NOT_FOUND = "IMAGE_NOT_FOUND", VERSION_NOT_FOUND = "VERSION_NOT_FOUND", VERSION_MANIFEST_CORRUPT = "VERSION_MANIFEST_CORRUPT", VERSION_LOCK_TIMEOUT = "VERSION_LOCK_TIMEOUT", VERSION_SAVE_ERROR = "VERSION_SAVE_ERROR", VERSION_RESTORE_ERROR = "VERSION_RESTORE_ERROR", PATTERN_INVALID = "PATTERN_INVALID", PATTERN_MISSING_TOKEN = "PATTERN_MISSING_TOKEN", UNKNOWN_ERROR = "UNKNOWN_ERROR" } /** * Base error class for all Writenex errors * * Provides structured error information including error code, * HTTP status, and optional context data for debugging. */ declare class WritenexError extends Error { /** Error code for categorization */ readonly code: WritenexErrorCode; /** HTTP status code for API responses */ readonly httpStatus: number; /** Additional context data for debugging */ readonly context?: Record; /** Original error if this wraps another error */ readonly cause?: Error; constructor(code: WritenexErrorCode, message: string, options?: { context?: Record; cause?: Error; }); /** * Convert error to JSON for API responses */ toJSON(): Record; /** * Create a user-friendly error message */ toUserMessage(): string; } /** * Error thrown when content was modified externally (conflict detection) * * This error includes both the server version and the client's expected mtime * to help resolve the conflict. */ declare class ContentConflictError extends WritenexError { /** Current content on disk */ readonly serverContent: string; /** Server's current mtime */ readonly serverMtime: number; /** Client's expected mtime */ readonly clientMtime: number; constructor(collection: string, contentId: string, serverContent: string, serverMtime: number, clientMtime: number); /** * Override toJSON to include conflict-specific data */ toJSON(): Record; } /** * Check if an error is a WritenexError */ declare function isWritenexError(error: unknown): error is WritenexError; export { ContentConflictError as C, WritenexError as W, WritenexErrorCode as a, isWritenexError as i };