import { HttpStatusCodes } from '../Server' ; import { Response } from './Response' ; export class ServerErrorResponse extends Response { public static create ( statusCode , message ? , data ? , meta ? ) { return new this ( { statusCode , message , data , meta } ) ; } public static internalServerError ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . InternalServerError , message , data , meta ) ; } public static notImplemented ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . NotImplemented , message , data , meta ) ; } public static badGateway ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . BadGateway , message , data , meta ) ; } public static serviceUnavailable ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . ServiceUnavailable , message , data , meta ) ; } public static gatewayTimeout ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . GatewayTimeout , message , data , meta ) ; } public static httpVersionNotSupported ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . HttpVersionNotSupported , message , data , meta ) ; } public static variantAlsoNegotiates ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . VariantAlsoNegotiates , message , data , meta ) ; } public static insufficientStorage ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . InsufficientStorage , message , data , meta ) ; } public static loopDetected ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . LoopDetected , message , data , meta ) ; } public static notExtended ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . NotExtended , message , data , meta ) ; } public static networkAuthenticationRequired ( message ? , data ? , meta ? ) { return this . create ( HttpStatusCodes . NetworkAuthenticationRequired , message , data , meta ) ; } format ( ) { const body = { } ; if ( this . message ) { body . message = this . message ; } if ( this . data ) { body . data = this . data ; } return body ; } }