UNPKG

docudb

Version:

Document-based NoSQL database for NodeJS

153 lines 3.98 kB
/** * Error handling module * Provides standardized error codes and error classes */ /** * Database error codes */ export interface DatabaseErrorCodes { NOT_INITIALIZED: string; INVALID_NAME: string; LOAD_ERROR: any; COLLECTION_ERROR: any; /** Error during database initialization */ INIT_ERROR: string; /** Collection not found */ COLLECTION_NOT_FOUND: string; /** Invalid collection name */ INVALID_COLLECTION_NAME: string; /** Collection already exists */ COLLECTION_ALREADY_EXISTS: string; /** Document not found */ DOCUMENT_NOT_FOUND: string; /** Invalid document ID */ INVALID_ID: string; /** Duplicate document ID */ DUPLICATE_ID: string; /** Invalid query syntax */ INVALID_QUERY: string; /** Invalid update operation */ INVALID_UPDATE: string; /** Transaction processing error */ TRANSACTION_ERROR: string; } /** * Schema error codes */ export interface SchemaErrorCodes { CUSTOM_VALIDATION_ERROR: string; INVALID_ENUM: any; INVALID_REGEX: any; INVALID_LENGTH: any; INVALID_VALUE: any; /** Invalid document structure */ INVALID_DOCUMENT: string; /** Missing required field */ REQUIRED_FIELD: string; /** Field has invalid type */ INVALID_TYPE: string; /** Validation rule failed */ VALIDATION_ERROR: string; /** Field not allowed in schema */ INVALID_FIELD: string; } /** * Storage error codes */ export interface StorageErrorCodes { SAVE_ERROR: any; INIT_ERROR: any; /** File not found */ FILE_NOT_FOUND: string; /** Error writing to storage */ WRITE_ERROR: string; /** Error reading from storage */ READ_ERROR: string; /** Error deleting from storage */ DELETE_ERROR: string; /** Error during compression/decompression */ COMPRESSION_ERROR: string; } /** * Index error codes */ export interface IndexErrorCodes { INVALID_FIELD_TYPE: string; LOAD_ERROR: any; SAVE_ERROR: any; UNIQUE_VIOLATION: any; INIT_ERROR: any; DROP_ERROR: any; /** Error creating index */ CREATE_ERROR: string; /** Error updating index */ UPDATE_ERROR: string; /** Error deleting index */ DELETE_ERROR: string; /** Unique constraint violation */ UNIQUE_CONSTRAINT: string; } export interface DocumentErrorCodes { INVALID_TYPE: string; DELETE_ERROR: string; LOCK_ERROR: string; UPDATE_ERROR: string; QUERY_ERROR: string; INVALID_ID: string; INVALID_DOCUMENT: string; NOT_FOUND: string; INSERT_ERROR: string; } export interface CollectionErrorCodes { METADATA_ERROR: string; DROP_ERROR: string; INVALID_NAME: string; INSERT_ERROR: any; } export interface CompressionErrorCodes { COMPRESS_ERROR: string; INSERT_ERROR: any; } export interface QueryErrorCodes { INVALID_OPERATOR: string; INSERT_ERROR: any; } export interface InsertErrorCodes { INSERT_ERROR: any; } /** * All error codes organized by module */ export interface ErrorCodes { QUERY: QueryErrorCodes; DOCUMENT: DocumentErrorCodes; COLLECTION: CollectionErrorCodes; COMPRESSION: CompressionErrorCodes; DATABASE: DatabaseErrorCodes; SCHEMA: SchemaErrorCodes; STORAGE: StorageErrorCodes; INDEX: IndexErrorCodes; } declare const MCO_ERROR: ErrorCodes; /** * Class for handling DocuDB errors * @extends Error */ declare class DocuDBError extends Error { code: string; details: any; timestamp: Date; /** * @param {string} message - Error message * @param {string} code - Error code from MCO_ERROR * @param {Object} details - Additional error details */ constructor(message: string, code: string, details?: any); /** * Converts the error to a JSON object * @returns {Object} - JSON representation of the error */ toJSON(): object; } export { MCO_ERROR, DocuDBError }; //# sourceMappingURL=errors.d.ts.map