26 lines · 676 B · TypeScript
RawDownload
/** * */export class HttpStatus extends Error {  public readonly status: number;  public readonly detail: string;   /**   *   * @param status   * @param detail   */  public constructor(status: number, detail: string) {    super(detail);    this.status = status;    this.detail = detail;  }} export const isHttpStatus = (value: unknown): value is HttpStatus => value instanceof HttpStatus; export const notFound = (detail: string): HttpStatus => new HttpStatus(404, detail); export const badRequest = (detail: string): HttpStatus => new HttpStatus(400, detail); export const serviceUnavailable = (detail: string): HttpStatus => new HttpStatus(503, detail);