/** * Custom error types for the application */ export class AppError extends Error { constructor( message: string, public readonly code: string, public readonly statusCode: number = 500, ) { super(message); this.name = 'AppError'; } } export class NotFoundError extends AppError { constructor(message = 'Resource not found') { super(message, 'NOT_FOUND', 404); this.name = 'NotFoundError'; } } export class ValidationError extends AppError { constructor(message = 'Validation failed') { super(message, 'VALIDATION_ERROR', 400); this.name = 'ValidationError'; } } export class UnauthorizedError extends AppError { constructor(message = 'Unauthorized') { super(message, 'UNAUTHORIZED', 401); this.name = 'UnauthorizedError'; } } export class ForbiddenError extends AppError { constructor(message = 'Forbidden') { super(message, 'FORBIDDEN', 403); this.name = 'ForbiddenError'; } } export class ConflictError extends AppError { constructor(message = 'Conflict') { super(message, 'CONFLICT', 409); this.name = 'ConflictError'; } }