/** * Database Error class for typed error handling */ import { DatabaseErrorType } from '../types/enums'; /** * Custom error class for database operations * Provides typed error handling with specific error types */ export declare class DatabaseError extends Error { /** Error type for categorization */ readonly type: DatabaseErrorType; /** Original error if wrapping another error */ readonly originalError?: Error; /** Error code (database-specific) */ readonly code?: string; /** Additional error details */ readonly details?: Record; constructor(message: string, type?: DatabaseErrorType, originalError?: Error, details?: Record); /** * Check if error is of a specific type */ isType(type: DatabaseErrorType): boolean; /** * Check if error is a connection error */ isConnectionError(): boolean; /** * Check if error is a query error */ isQueryError(): boolean; /** * Check if error is a unique violation */ isUniqueViolation(): boolean; /** * Check if error is a foreign key violation */ isForeignKeyViolation(): boolean; /** * Check if error is a not null violation */ isNotNullViolation(): boolean; /** * Check if error is a validation error */ isValidationError(): boolean; /** * Check if error is a not found error */ isNotFound(): boolean; /** * Convert to JSON for logging */ toJSON(): Record; /** * Create a connection error */ static connectionError(message: string, originalError?: Error): DatabaseError; /** * Create a query error */ static queryError(message: string, originalError?: Error): DatabaseError; /** * Create a unique violation error */ static uniqueViolation(message: string, originalError?: Error): DatabaseError; /** * Create a foreign key violation error */ static foreignKeyViolation(message: string, originalError?: Error): DatabaseError; /** * Create a not found error */ static notFound(message: string): DatabaseError; /** * Create a validation error */ static validationError(message: string, details?: Record): DatabaseError; /** * Create a transaction error */ static transactionError(message: string, originalError?: Error): DatabaseError; /** * Create a schema error */ static schemaError(message: string, originalError?: Error): DatabaseError; /** * Create a migration error */ static migrationError(message: string, originalError?: Error): DatabaseError; /** * Create an error from a database-specific error * Maps common database error codes to DatabaseErrorType */ static fromDatabaseError(error: any, databaseType: string): DatabaseError; }