UNPKG

4.34 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3class ValidationError extends Error {
4 constructor(message, expose = true, validation, fileName, lineNumber) {
5 super(message);
6 this.status = 400;
7 this.statusCode = 400;
8 if (typeof fileName !== undefined)
9 this.fileName = fileName;
10 if (typeof lineNumber !== undefined)
11 this.lineNumber = lineNumber;
12 this.message = message || "The data is not valid.";
13 this.expose = expose;
14 this.validation = validation || {};
15 this.status = this.statusCode = 400;
16 }
17}
18exports.ValidationError = ValidationError;
19class UnsupportedMediaTypeError extends Error {
20 constructor(message, expose = true, fileName, lineNumber) {
21 super(message);
22 this.status = 415;
23 this.statusCode = 415;
24 if (typeof fileName !== undefined)
25 this.fileName = fileName;
26 if (typeof lineNumber !== undefined)
27 this.lineNumber = lineNumber;
28 this.message = message || "The media type is unsupported.";
29 this.expose = expose;
30 }
31}
32exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
33class NotFoundError extends Error {
34 constructor(message, expose = true, fileName, lineNumber) {
35 super(message);
36 this.status = 404;
37 this.statusCode = 404;
38 if (typeof fileName !== undefined)
39 this.fileName = fileName;
40 if (typeof lineNumber !== undefined)
41 this.lineNumber = lineNumber;
42 this.message = message || "The resource does not exist.";
43 this.expose = expose;
44 }
45}
46exports.NotFoundError = NotFoundError;
47class ConflictError extends Error {
48 constructor(message, expose = true, fileName, lineNumber) {
49 super(message);
50 this.status = 409;
51 this.statusCode = 409;
52 if (typeof fileName !== undefined)
53 this.fileName = fileName;
54 if (typeof lineNumber !== undefined)
55 this.lineNumber = lineNumber;
56 this.message = message || "A duplicate resource already exists.";
57 this.expose = expose;
58 }
59}
60exports.ConflictError = ConflictError;
61class AuthenticationError extends Error {
62 constructor(message, expose = true, fileName, lineNumber) {
63 super(message);
64 this.status = 401;
65 this.statusCode = 401;
66 if (typeof fileName !== undefined)
67 this.fileName = fileName;
68 if (typeof lineNumber !== undefined)
69 this.lineNumber = lineNumber;
70 this.message = message || "Authentication failed.";
71 this.expose = expose;
72 }
73}
74exports.AuthenticationError = AuthenticationError;
75class ForbiddenError extends Error {
76 constructor(message, expose = true, fileName, lineNumber) {
77 super(message);
78 this.status = 403;
79 this.statusCode = 403;
80 if (typeof fileName !== undefined)
81 this.fileName = fileName;
82 if (typeof lineNumber !== undefined)
83 this.lineNumber = lineNumber;
84 this.message = message || "The action is forbidden.";
85 this.expose = expose;
86 }
87}
88exports.ForbiddenError = ForbiddenError;
89class ServerError extends Error {
90 constructor(message, expose = true, fileName, lineNumber) {
91 super(message);
92 this.status = 500;
93 this.statusCode = 500;
94 if (typeof fileName !== undefined)
95 this.fileName = fileName;
96 if (typeof lineNumber !== undefined)
97 this.lineNumber = lineNumber;
98 this.message = message || "An unknown error has occurred.";
99 this.expose = expose;
100 this.status = this.statusCode = 500;
101 }
102}
103exports.ServerError = ServerError;
104class NotImplementedError extends Error {
105 constructor(message, expose = true, fileName, lineNumber) {
106 super(message);
107 this.status = 501;
108 this.statusCode = 501;
109 if (typeof fileName !== undefined)
110 this.fileName = fileName;
111 if (typeof lineNumber !== undefined)
112 this.lineNumber = lineNumber;
113 this.message = message || "The requested functionality is not implemented.";
114 this.expose = expose;
115 this.status = this.statusCode = 501;
116 }
117}
118exports.NotImplementedError = NotImplementedError;
119//# sourceMappingURL=errors.js.map
\No newline at end of file