spb/cancerindex
Public
TypeScript 97.2%
SQL 1.5%
CSS 0.6%
JavaScript 0.5%
1/** Typed HTTP errors mapped by the global error handler in app.ts. */2export class HttpError extends Error {3 constructor(4 public readonly statusCode: number,5 public readonly code: string,6 message: string,7 public readonly details?: unknown,8 ) {9 super(message);10 }11}1213export class NotFound extends HttpError {14 constructor(entity: string, ref: string) {15 super(404, 'not_found', `${entity} "${ref}" not found`);16 }17}1819export class BadRequest extends HttpError {20 constructor(message: string, details?: unknown) {21 super(400, 'bad_request', message, details);22 }23}2425export class Unauthorized extends HttpError {26 constructor(message = 'unauthorized') {27 super(401, 'unauthorized', message);28 }29}3031export class ServiceUnavailable extends HttpError {32 constructor(message: string) {33 super(503, 'service_unavailable', message);34 }35}36