export class ApiError extends Error { constructor(statusCode, message, details = undefined) { super(message); this.name = 'ApiError'; this.statusCode = statusCode; this.details = details; Error.captureStackTrace?.(this, this.constructor); } static badRequest(message, details) { return new ApiError(400, message, details); } static unauthorized(message = 'Authentication required') { return new ApiError(401, message); } static forbidden(message = 'Forbidden') { return new ApiError(403, message); } static notFound(message = 'Resource not found') { return new ApiError(404, message); } static conflict(message = 'Resource already exists') { return new ApiError(409, message); } }