UNPKG

2.32 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const Server_1 = require("../Server");
4const Response_1 = require("./Response");
5class ServerErrorResponse extends Response_1.Response {
6 static create(statusCode, message, data, meta) {
7 return new this({ statusCode, message, data, meta });
8 }
9 static internalServerError(message, data, meta) {
10 return this.create(Server_1.HttpStatusCodes.InternalServerError, message, data, meta);
11 }
12 static notImplemented(message, data, meta) {
13 return this.create(Server_1.HttpStatusCodes.NotImplemented, message, data, meta);
14 }
15 static badGateway(message, data, meta) {
16 return this.create(Server_1.HttpStatusCodes.BadGateway, message, data, meta);
17 }
18 static serviceUnavailable(message, data, meta) {
19 return this.create(Server_1.HttpStatusCodes.ServiceUnavailable, message, data, meta);
20 }
21 static gatewayTimeout(message, data, meta) {
22 return this.create(Server_1.HttpStatusCodes.GatewayTimeout, message, data, meta);
23 }
24 static httpVersionNotSupported(message, data, meta) {
25 return this.create(Server_1.HttpStatusCodes.HttpVersionNotSupported, message, data, meta);
26 }
27 static variantAlsoNegotiates(message, data, meta) {
28 return this.create(Server_1.HttpStatusCodes.VariantAlsoNegotiates, message, data, meta);
29 }
30 static insufficientStorage(message, data, meta) {
31 return this.create(Server_1.HttpStatusCodes.InsufficientStorage, message, data, meta);
32 }
33 static loopDetected(message, data, meta) {
34 return this.create(Server_1.HttpStatusCodes.LoopDetected, message, data, meta);
35 }
36 static notExtended(message, data, meta) {
37 return this.create(Server_1.HttpStatusCodes.NotExtended, message, data, meta);
38 }
39 static networkAuthenticationRequired(message, data, meta) {
40 return this.create(Server_1.HttpStatusCodes.NetworkAuthenticationRequired, message, data, meta);
41 }
42 format() {
43 const body = {};
44 if (this.message) {
45 body.message = this.message;
46 }
47 if (this.data) {
48 body.data = this.data;
49 }
50 return body;
51 }
52}
53exports.ServerErrorResponse = ServerErrorResponse;
54//# sourceMappingURL=ServerErrorResponse.js.map
\No newline at end of file