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