2020-07-30 14:30:43 +00:00
|
|
|
import {HTTPStatus, Message} from '../const/http.ts'
|
|
|
|
|
2020-08-16 19:31:47 +00:00
|
|
|
/**
|
|
|
|
* Error class representing an HTTP error.
|
|
|
|
* @extends Error
|
|
|
|
*/
|
2020-07-30 14:30:43 +00:00
|
|
|
export default class HTTPError extends Error {
|
|
|
|
constructor(
|
2020-08-16 19:31:47 +00:00
|
|
|
/**
|
|
|
|
* The associated HTTP status code.
|
|
|
|
* @type HTTPStatus
|
|
|
|
*/
|
2020-07-30 14:30:43 +00:00
|
|
|
public readonly http_status: HTTPStatus,
|
2020-08-16 19:31:47 +00:00
|
|
|
/**
|
|
|
|
* The associated message.
|
|
|
|
* @type string
|
|
|
|
*/
|
2020-07-30 14:30:43 +00:00
|
|
|
public readonly http_message?: string
|
|
|
|
) {
|
|
|
|
super(`HTTP ${http_status}: ${http_message || Message[http_status]}`)
|
|
|
|
}
|
|
|
|
}
|