/** * Base exception class for all Rich Domain exceptions */ declare abstract class DomainException extends Error { readonly code: string; readonly timestamp: Date; readonly __isDomainException = true; constructor(message: string, code?: string); /** * Check if an error is a DomainException */ static isDomainException(error: unknown): error is DomainException; /** * Convert to JSON for serialization */ toJSON(): { name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a domain rule or business logic is violated */ export declare class DomainError extends DomainException { constructor(message: string, code?: string); } /** * Thrown for general application errors that don't fit other domain exceptions. */ export declare class ApplicationError extends DomainException { constructor(message: string, code?: string); } /** * Thrown when authentication is required but not provided or invalid */ export declare class UnauthorizedError extends DomainException { readonly resource?: string; readonly action?: string; constructor(message?: string, resource?: string, action?: string); toJSON(): { resource: string | undefined; action: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when the user is authenticated but doesn't have permission to perform an action */ export declare class ForbiddenError extends DomainException { readonly resource?: string; readonly action?: string; readonly userId?: string; constructor(message?: string, resource?: string, action?: string, userId?: string); toJSON(): { resource: string | undefined; action: string | undefined; userId: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a request is malformed or contains invalid data */ export declare class BadRequestError extends DomainException { readonly field?: string; readonly reason?: string; constructor(message: string, field?: string, reason?: string); toJSON(): { field: string | undefined; reason: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when an operation exceeds the allowed time limit */ export declare class TimeoutError extends DomainException { readonly operation: string; readonly timeoutMs?: number; constructor(operation: string, timeoutMs?: number, message?: string); toJSON(): { operation: string; timeoutMs: number | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when rate limit is exceeded */ export declare class RateLimitError extends DomainException { readonly limit: number; readonly windowMs: number; readonly retryAfter?: number; constructor(limit: number, windowMs: number, retryAfter?: number, message?: string); toJSON(): { limit: number; windowMs: number; retryAfter: number | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when an entity or aggregate is not found */ export declare class EntityNotFoundError extends DomainException { readonly entityType: string; readonly entityId?: string; constructor(entityType: string, entityId?: string, message?: string); toJSON(): { entityType: string; entityId: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when trying to create an entity that already exists */ export declare class EntityAlreadyExistsError extends DomainException { readonly entityType: string; readonly entityId?: string; constructor(entityType: string, entityId?: string, message?: string); toJSON(): { entityType: string; entityId: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Base exception for repository operations */ export declare class RepositoryError extends DomainException { constructor(message: string, code?: string); } /** * Thrown when a persistence operation fails */ export declare class PersistenceError extends RepositoryError { readonly operation: string; readonly cause?: Error; constructor(operation: string, message?: string, cause?: Error); toJSON(): { operation: string; cause: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a concurrency conflict occurs (optimistic locking) */ export declare class ConcurrencyError extends RepositoryError { readonly entityType: string; readonly entityId: string; constructor(entityType: string, entityId: string, message?: string); toJSON(): { entityType: string; entityId: string; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a database constraint is violated */ export declare class ConstraintViolationError extends RepositoryError { readonly constraint: string; constructor(constraint: string, message?: string); toJSON(): { constraint: string; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a value object has invalid data */ export declare class InvalidValueObjectError extends DomainException { readonly valueObjectType: string; readonly invalidValue?: any; constructor(valueObjectType: string, message: string, invalidValue?: any); toJSON(): { valueObjectType: string; invalidValue: any; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a domain event operation fails */ export declare class DomainEventError extends DomainException { readonly eventType?: string; constructor(message: string, eventType?: string); toJSON(): { eventType: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when an event handler fails */ export declare class EventHandlerError extends DomainEventError { readonly handlerName: string; readonly cause?: Error; constructor(handlerName: string, eventType: string, cause?: Error); toJSON(): { handlerName: string; cause: string | undefined; eventType: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a criteria or query is invalid */ export declare class InvalidCriteriaError extends DomainException { readonly field?: string; constructor(message: string, field?: string); toJSON(): { field: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a transaction operation fails */ export declare class TransactionError extends DomainException { readonly operation: string; readonly cause?: Error; constructor(operation: string, message?: string, cause?: Error); toJSON(): { operation: string; cause: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when an unexpected or unknown error occurs */ export declare class UnknownError extends DomainException { readonly originalError?: Error; constructor(message?: string, originalError?: Error); toJSON(): { originalError: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a feature is not implemented yet */ export declare class NotImplementedError extends DomainException { readonly feature: string; constructor(feature: string, message?: string); toJSON(): { feature: string; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when a required configuration is missing */ export declare class ConfigurationError extends DomainException { readonly configKey?: string; constructor(message: string, configKey?: string); toJSON(): { configKey: string | undefined; name: string; message: string; code: string; timestamp: string; }; } /** * Thrown when mapping between domain and persistence fails */ export declare class MapperError extends DomainException { readonly direction: "toDomain" | "toPersistence"; readonly entityType: string; readonly cause?: Error; constructor(direction: "toDomain" | "toPersistence", entityType: string, message?: string, cause?: Error); toJSON(): { direction: "toDomain" | "toPersistence"; entityType: string; cause: string | undefined; name: string; message: string; code: string; timestamp: string; }; } export {}; //# sourceMappingURL=exceptions.d.ts.map