/** Typed HTTP errors mapped by the global error handler in app.ts. */ export class HttpError extends Error { constructor( public readonly statusCode: number, public readonly code: string, message: string, public readonly details?: unknown, ) { super(message); } } export class NotFound extends HttpError { constructor(entity: string, ref: string) { super(404, 'not_found', `${entity} "${ref}" not found`); } } export class BadRequest extends HttpError { constructor(message: string, details?: unknown) { super(400, 'bad_request', message, details); } } export class Unauthorized extends HttpError { constructor(message = 'unauthorized') { super(401, 'unauthorized', message); } } export class ServiceUnavailable extends HttpError { constructor(message: string) { super(503, 'service_unavailable', message); } }