This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182// SPDX-License-Identifier: AGPL-3.0-or-later
import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';import {HttpStatus} from '@fluxer/constants/src/HttpConstants';import {FluxerError, type FluxerErrorData} from '@fluxer/errors/src/FluxerError';
interface HttpErrorOptions { code?: string; message?: string; data?: FluxerErrorData; headers?: Record<string, string>; cause?: Error;}
export class BadRequestError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.BAD_REQUEST, message: options.message ?? 'Bad Request', status: HttpStatus.BAD_REQUEST, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'BadRequestError'; }}
export class UnauthorizedError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.UNAUTHORIZED, message: options.message ?? 'Unauthorized', status: HttpStatus.UNAUTHORIZED, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'UnauthorizedError'; }}
export class ForbiddenError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.FORBIDDEN, message: options.message ?? 'Forbidden', status: HttpStatus.FORBIDDEN, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'ForbiddenError'; }}
export class NotFoundError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.NOT_FOUND, message: options.message ?? 'Not Found', status: HttpStatus.NOT_FOUND, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'NotFoundError'; }}
export class MethodNotAllowedError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.METHOD_NOT_ALLOWED, message: options.message ?? 'Method Not Allowed', status: HttpStatus.METHOD_NOT_ALLOWED, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'MethodNotAllowedError'; }}
export class ConflictError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.CONFLICT, message: options.message ?? 'Conflict', status: HttpStatus.CONFLICT, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'ConflictError'; }}
export class GoneError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.GONE, message: options.message ?? 'Gone', status: HttpStatus.GONE, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'GoneError'; }}
export class InternalServerError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.INTERNAL_SERVER_ERROR, message: options.message ?? 'Internal Server Error', status: HttpStatus.INTERNAL_SERVER_ERROR, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'InternalServerError'; }}
export class NotImplementedError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.NOT_IMPLEMENTED, message: options.message ?? 'Not Implemented', status: HttpStatus.NOT_IMPLEMENTED, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'NotImplementedError'; }}
export class ServiceUnavailableError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.SERVICE_UNAVAILABLE, message: options.message ?? 'Service Unavailable', status: HttpStatus.SERVICE_UNAVAILABLE, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'ServiceUnavailableError'; }}
export class BadGatewayError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.BAD_GATEWAY, message: options.message ?? 'Bad Gateway', status: HttpStatus.BAD_GATEWAY, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'BadGatewayError'; }}
export class GatewayTimeoutError extends FluxerError { constructor(options: HttpErrorOptions = {}) { super({ code: options.code ?? APIErrorCodes.GATEWAY_TIMEOUT, message: options.message ?? 'Gateway Timeout', status: HttpStatus.GATEWAY_TIMEOUT, data: options.data, headers: options.headers, cause: options.cause, }); this.name = 'GatewayTimeoutError'; }}