// Custom error classes for all services export class AppError extends Error { constructor( message: string, public code: string, public statusCode: number = 500, public details?: Record, ) { super(message); this.name = "AppError"; } } export class ValidationError extends AppError { constructor(message: string, details?: Record) { super(message, "VALIDATION_ERROR", 400, details); this.name = "ValidationError"; } } export class NotFoundError extends AppError { constructor(resource: string, id?: string) { super(`${resource} not found${id ? `: ${id}` : ""}`, "NOT_FOUND", 404); this.name = "NotFoundError"; } } export class UnauthorizedError extends AppError { constructor(message = "Unauthorized") { super(message, "UNAUTHORIZED", 401); this.name = "UnauthorizedError"; } } export class DatabaseError extends AppError { constructor(message: string, details?: Record) { super(message, "DATABASE_ERROR", 500, details); this.name = "DatabaseError"; } } export class ConfigError extends AppError { constructor(message: string) { super(message, "CONFIG_ERROR", 500); this.name = "ConfigError"; } }