You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
import { IFormNotification } from '../types'
|
|
|
|
export class HttpError extends Error {
|
|
statusCode: number
|
|
errors: IFormNotification[]
|
|
|
|
constructor(message = 'Unknown Error') {
|
|
super(message)
|
|
|
|
this.name = 'HttpError'
|
|
this.statusCode = 500
|
|
this.errors = []
|
|
}
|
|
}
|
|
|
|
export class ServerError extends HttpError {
|
|
constructor() {
|
|
super('Server Error')
|
|
|
|
this.name = 'ServerError'
|
|
this.statusCode = 500
|
|
}
|
|
}
|
|
|
|
export class BadRequestError extends HttpError {
|
|
constructor(message = 'Bad Request', errors: IFormNotification[] = []) {
|
|
super(message)
|
|
|
|
this.name = 'BadRequestError'
|
|
this.statusCode = 400
|
|
this.errors = errors
|
|
}
|
|
}
|
|
|
|
export class UnauthorizedError extends HttpError {
|
|
constructor(message = 'Unauthorized') {
|
|
super(message)
|
|
|
|
this.name = 'UnauthorizedError'
|
|
this.statusCode = 401
|
|
}
|
|
}
|
|
|
|
export class ForbiddenError extends HttpError {
|
|
constructor(message = 'Forbidden') {
|
|
super(message)
|
|
|
|
this.name = 'ForbiddenError'
|
|
this.statusCode = 403
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends HttpError {
|
|
constructor(message = 'Not Found') {
|
|
super(message)
|
|
|
|
this.name = 'NotFoundError'
|
|
this.statusCode = 404
|
|
}
|
|
}
|