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