1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | class 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 | }
|
18 | exports.ValidationError = ValidationError;
|
19 | class 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 | }
|
32 | exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
33 | class 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 | }
|
46 | exports.NotFoundError = NotFoundError;
|
47 | class 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 | }
|
60 | exports.ConflictError = ConflictError;
|
61 | class 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 | }
|
74 | exports.AuthenticationError = AuthenticationError;
|
75 | class 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 | }
|
88 | exports.ForbiddenError = ForbiddenError;
|
89 | class 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 | }
|
103 | exports.ServerError = ServerError;
|
104 | class 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 | }
|
118 | exports.NotImplementedError = NotImplementedError;
|
119 |
|
\ | No newline at end of file |