lib/src/http/HTTPError.ts
garrettmills f496046461
All checks were successful
continuous-integration/drone/push Build is passing
File-based response support & static server
- Clean up UniversalPath implementation
    - Use Readable/Writable types correctly for stream methods
    - Add .list() methods for getting child files

- Make Response body specify explicit types and support
  writing Readable streams to the body

- Create a static file server that supports directory listing
2021-07-07 20:13:23 -05:00

19 lines
562 B
TypeScript

import {ErrorWithContext, HTTPStatus, HTTPMessage} from '../util'
/**
* An error class that has an associated HTTP status.
*
* When thrown inside the request lifecycle, this will result in the HTTP
* status code being applied to the response.
*/
export class HTTPError extends ErrorWithContext {
constructor(
public readonly status: HTTPStatus = 500,
public readonly message: string = '',
context?: {[key: string]: any},
) {
super('HTTP ERROR', context)
this.message = message || HTTPMessage[status]
}
}