import {ErrorResponseFactory} from './ErrorResponseFactory' import {HTTPError} from '../HTTPError' import {HTTPStatus} from '../../util' /** * Helper that generates a new HTTPErrorResponseFactory given the HTTP status and message. * @param status * @param message * @param output */ export function http(status: HTTPStatus, message?: string, output: 'json' | 'html' | 'auto' = 'auto'): HTTPErrorResponseFactory { return new HTTPErrorResponseFactory(new HTTPError(status, message), output) } /** * Response factory that renders the given HTTPError in the specified output format. */ export class HTTPErrorResponseFactory extends ErrorResponseFactory { constructor( public readonly error: HTTPError, output: 'json' | 'html' | 'auto' = 'auto', // FIXME xml support ) { super(error, error.status, output) } }