@nest-yalc-2/errors 1.3.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/__tests__/database-exception.filter.spec.ts +1 -1
- package/src/__tests__/default.error.spec.ts +1 -1
- package/src/__tests__/errors.enum.spec.ts +1 -1
- package/src/__tests__/http-exception.filter.spec.ts +54 -1
- package/src/__tests__/http-status-code-to-errors.spec.ts +1 -1
- package/src/__tests__/input-validation.error.spec.ts +1 -1
- package/src/__tests__/login.error.spec.ts +1 -1
- package/src/__tests__/system-exception.filter.spec.ts +1 -1
- package/src/__tests__/verification.error.spec.ts +1 -1
- package/src/filters/database-exception.filter.d.ts +2 -1
- package/src/filters/database-exception.filter.js +5 -46
- package/src/filters/database-exception.filter.js.map +1 -1
- package/src/filters/database-exception.filter.ts +4 -2
- package/src/filters/http-exception.filter.d.ts +4 -3
- package/src/filters/http-exception.filter.js +5 -46
- package/src/filters/http-exception.filter.js.map +1 -1
- package/src/filters/http-exception.filter.ts +4 -3
- package/src/filters/system-exception.filter.js +4 -12
- package/src/filters/system-exception.filter.js.map +1 -1
- package/src/filters/system-exception.filter.ts +1 -1
- package/src/filters/validation-exception.filter.d.ts +2 -2
- package/src/filters/validation-exception.filter.js +4 -45
- package/src/filters/validation-exception.filter.js.map +1 -1
- package/src/filters/validation-exception.filter.ts +3 -1
- package/src/index.d.ts +2 -4
- package/src/index.js +3 -18
- package/src/index.js.map +1 -1
- package/src/index.ts +2 -4
- package/src/default.error.d.ts +0 -93
- package/src/default.error.js +0 -266
- package/src/default.error.js.map +0 -1
- package/src/default.error.ts +0 -640
- package/src/error.class.d.ts +0 -103
- package/src/error.class.js +0 -170
- package/src/error.class.js.map +0 -1
- package/src/error.class.ts +0 -319
- package/src/error.enum.d.ts +0 -29
- package/src/error.enum.js +0 -41
- package/src/error.enum.js.map +0 -1
- package/src/error.enum.ts +0 -45
- package/src/error.helper.d.ts +0 -2
- package/src/error.helper.js +0 -20
- package/src/error.helper.js.map +0 -1
- package/src/error.helper.ts +0 -34
- package/src/http-status-code-to-errors.d.ts +0 -4
- package/src/http-status-code-to-errors.js +0 -24
- package/src/http-status-code-to-errors.js.map +0 -1
- package/src/http-status-code-to-errors.ts +0 -41
- package/src/result.error.d.ts +0 -4
- package/src/result.error.js +0 -24
- package/src/result.error.js.map +0 -1
- package/src/result.error.ts +0 -25
package/src/error.class.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { BadRequestException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, InternalServerErrorException, HttpException, HttpStatus, MethodNotAllowedException, NotAcceptableException, GoneException, UnsupportedMediaTypeException, UnprocessableEntityException, NotImplementedException, BadGatewayException, ServiceUnavailableException, GatewayTimeoutException } from '@nestjs/common';
|
|
2
|
-
import { IDefaultErrorBaseOptions } from './default.error.js';
|
|
3
|
-
declare const BadRequestError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof BadRequestException>;
|
|
4
|
-
export declare class BadRequestError extends BadRequestError_base {
|
|
5
|
-
static defaultStatusCode: HttpStatus;
|
|
6
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
7
|
-
}
|
|
8
|
-
declare const UnauthorizedError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof UnauthorizedException>;
|
|
9
|
-
export declare class UnauthorizedError extends UnauthorizedError_base {
|
|
10
|
-
static defaultStatusCode: HttpStatus;
|
|
11
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
12
|
-
}
|
|
13
|
-
declare const ForbiddenError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof ForbiddenException>;
|
|
14
|
-
export declare class ForbiddenError extends ForbiddenError_base {
|
|
15
|
-
static defaultStatusCode: HttpStatus;
|
|
16
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
17
|
-
}
|
|
18
|
-
declare const NotFoundError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof NotFoundException>;
|
|
19
|
-
export declare class NotFoundError extends NotFoundError_base {
|
|
20
|
-
static defaultStatusCode: HttpStatus;
|
|
21
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
22
|
-
}
|
|
23
|
-
declare const ConflictError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof ConflictException>;
|
|
24
|
-
export declare class ConflictError extends ConflictError_base {
|
|
25
|
-
static defaultStatusCode: HttpStatus;
|
|
26
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
27
|
-
}
|
|
28
|
-
declare const InternalServerError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof InternalServerErrorException>;
|
|
29
|
-
export declare class InternalServerError extends InternalServerError_base {
|
|
30
|
-
static defaultStatusCode: HttpStatus;
|
|
31
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
32
|
-
}
|
|
33
|
-
declare const PaymentRequiredError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof HttpException>;
|
|
34
|
-
export declare class PaymentRequiredError extends PaymentRequiredError_base {
|
|
35
|
-
static defaultStatusCode: HttpStatus;
|
|
36
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
37
|
-
}
|
|
38
|
-
declare const MethodNotAllowedError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof MethodNotAllowedException>;
|
|
39
|
-
export declare class MethodNotAllowedError extends MethodNotAllowedError_base {
|
|
40
|
-
static defaultStatusCode: HttpStatus;
|
|
41
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
42
|
-
}
|
|
43
|
-
declare const NotAcceptableError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof NotAcceptableException>;
|
|
44
|
-
export declare class NotAcceptableError extends NotAcceptableError_base {
|
|
45
|
-
static defaultStatusCode: HttpStatus;
|
|
46
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
47
|
-
}
|
|
48
|
-
declare const GoneError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof GoneException>;
|
|
49
|
-
export declare class GoneError extends GoneError_base {
|
|
50
|
-
static defaultStatusCode: HttpStatus;
|
|
51
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
52
|
-
}
|
|
53
|
-
declare const UnsupportedMediaTypeError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof UnsupportedMediaTypeException>;
|
|
54
|
-
export declare class UnsupportedMediaTypeError extends UnsupportedMediaTypeError_base {
|
|
55
|
-
static defaultStatusCode: HttpStatus;
|
|
56
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
57
|
-
}
|
|
58
|
-
declare const UnprocessableEntityError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof UnprocessableEntityException>;
|
|
59
|
-
export declare class UnprocessableEntityError extends UnprocessableEntityError_base {
|
|
60
|
-
static defaultStatusCode: HttpStatus;
|
|
61
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
62
|
-
}
|
|
63
|
-
declare const TooManyRequestsError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof HttpException>;
|
|
64
|
-
export declare class TooManyRequestsError extends TooManyRequestsError_base {
|
|
65
|
-
static defaultStatusCode: HttpStatus;
|
|
66
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
67
|
-
}
|
|
68
|
-
declare const NotImplementedError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof NotImplementedException>;
|
|
69
|
-
export declare class NotImplementedError extends NotImplementedError_base {
|
|
70
|
-
static defaultStatusCode: HttpStatus;
|
|
71
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
72
|
-
}
|
|
73
|
-
declare const BadGatewayError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof BadGatewayException>;
|
|
74
|
-
export declare class BadGatewayError extends BadGatewayError_base {
|
|
75
|
-
static defaultStatusCode: HttpStatus;
|
|
76
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
77
|
-
}
|
|
78
|
-
declare const ServiceUnavailableError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof ServiceUnavailableException>;
|
|
79
|
-
export declare class ServiceUnavailableError extends ServiceUnavailableError_base {
|
|
80
|
-
static defaultStatusCode: HttpStatus;
|
|
81
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
82
|
-
}
|
|
83
|
-
declare const GatewayTimeoutError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof GatewayTimeoutException>;
|
|
84
|
-
export declare class GatewayTimeoutError extends GatewayTimeoutError_base {
|
|
85
|
-
static defaultStatusCode: HttpStatus;
|
|
86
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
87
|
-
}
|
|
88
|
-
declare const AdditionalVerificationNeededError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof HttpException>;
|
|
89
|
-
export declare class AdditionalVerificationNeededError extends AdditionalVerificationNeededError_base {
|
|
90
|
-
static defaultStatusCode: any;
|
|
91
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
92
|
-
}
|
|
93
|
-
declare const LoginError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof UnauthorizedException>;
|
|
94
|
-
export declare class LoginError extends LoginError_base {
|
|
95
|
-
static defaultStatusCode: HttpStatus;
|
|
96
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
97
|
-
}
|
|
98
|
-
declare const InputValidationError_base: import("./default.error.js").IDefaultErrorBaseConstructor<typeof BadRequestException>;
|
|
99
|
-
export declare class InputValidationError extends InputValidationError_base {
|
|
100
|
-
static defaultStatusCode: HttpStatus;
|
|
101
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions);
|
|
102
|
-
}
|
|
103
|
-
export {};
|
package/src/error.class.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InputValidationError = exports.LoginError = exports.AdditionalVerificationNeededError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.NotImplementedError = exports.TooManyRequestsError = exports.UnprocessableEntityError = exports.UnsupportedMediaTypeError = exports.GoneError = exports.NotAcceptableError = exports.MethodNotAllowedError = exports.PaymentRequiredError = exports.InternalServerError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const error_enum_js_1 = require("./error.enum.js");
|
|
6
|
-
const default_error_js_1 = require("./default.error.js");
|
|
7
|
-
const axios_1 = require("axios");
|
|
8
|
-
function buildArgs(errorName, internalMessage, options) {
|
|
9
|
-
const { cause, description, response, ...restOptions } = options ?? {};
|
|
10
|
-
return [
|
|
11
|
-
internalMessage ? `${errorName}: ${internalMessage}` : errorName,
|
|
12
|
-
{ ...(restOptions ?? {}), description },
|
|
13
|
-
response ?? {},
|
|
14
|
-
{
|
|
15
|
-
cause,
|
|
16
|
-
description,
|
|
17
|
-
},
|
|
18
|
-
];
|
|
19
|
-
}
|
|
20
|
-
function buildArgsHttpException(errorName, internalMessage, options, errorCode) {
|
|
21
|
-
const args = buildArgs(errorName, internalMessage, options);
|
|
22
|
-
return [
|
|
23
|
-
args[0],
|
|
24
|
-
args[1],
|
|
25
|
-
args[2],
|
|
26
|
-
errorCode ?? common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
27
|
-
typeof args[3] === 'string' ? { description: args[3] } : args[3],
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
class BadRequestError extends (0, default_error_js_1.DefaultErrorBase)(common_1.BadRequestException) {
|
|
31
|
-
static { this.defaultStatusCode = common_1.HttpStatus.BAD_REQUEST; }
|
|
32
|
-
constructor(internalMessage, options) {
|
|
33
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.BAD_REQUEST, internalMessage, options));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.BadRequestError = BadRequestError;
|
|
37
|
-
class UnauthorizedError extends (0, default_error_js_1.DefaultErrorBase)(common_1.UnauthorizedException) {
|
|
38
|
-
static { this.defaultStatusCode = common_1.HttpStatus.UNAUTHORIZED; }
|
|
39
|
-
constructor(internalMessage, options) {
|
|
40
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.UNAUTHORIZED, internalMessage, options));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.UnauthorizedError = UnauthorizedError;
|
|
44
|
-
class ForbiddenError extends (0, default_error_js_1.DefaultErrorBase)(common_1.ForbiddenException) {
|
|
45
|
-
static { this.defaultStatusCode = common_1.HttpStatus.FORBIDDEN; }
|
|
46
|
-
constructor(internalMessage, options) {
|
|
47
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.FORBIDDEN, internalMessage, options));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ForbiddenError = ForbiddenError;
|
|
51
|
-
class NotFoundError extends (0, default_error_js_1.DefaultErrorBase)(common_1.NotFoundException) {
|
|
52
|
-
static { this.defaultStatusCode = common_1.HttpStatus.NOT_FOUND; }
|
|
53
|
-
constructor(internalMessage, options) {
|
|
54
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.NOT_FOUND, internalMessage, options));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.NotFoundError = NotFoundError;
|
|
58
|
-
class ConflictError extends (0, default_error_js_1.DefaultErrorBase)(common_1.ConflictException) {
|
|
59
|
-
static { this.defaultStatusCode = common_1.HttpStatus.CONFLICT; }
|
|
60
|
-
constructor(internalMessage, options) {
|
|
61
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.CONFLICT, internalMessage, options));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.ConflictError = ConflictError;
|
|
65
|
-
class InternalServerError extends (0, default_error_js_1.DefaultErrorBase)(common_1.InternalServerErrorException) {
|
|
66
|
-
static { this.defaultStatusCode = common_1.HttpStatus.INTERNAL_SERVER_ERROR; }
|
|
67
|
-
constructor(internalMessage, options) {
|
|
68
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.INTERNAL_SERVER_ERROR, internalMessage, options));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.InternalServerError = InternalServerError;
|
|
72
|
-
class PaymentRequiredError extends (0, default_error_js_1.DefaultErrorBase)(common_1.HttpException) {
|
|
73
|
-
static { this.defaultStatusCode = common_1.HttpStatus.PAYMENT_REQUIRED; }
|
|
74
|
-
constructor(internalMessage, options) {
|
|
75
|
-
super(...buildArgsHttpException(error_enum_js_1.ErrorsEnum.PAYMENT_REQUIRED, internalMessage, options, PaymentRequiredError.defaultStatusCode));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.PaymentRequiredError = PaymentRequiredError;
|
|
79
|
-
class MethodNotAllowedError extends (0, default_error_js_1.DefaultErrorBase)(common_1.MethodNotAllowedException) {
|
|
80
|
-
static { this.defaultStatusCode = common_1.HttpStatus.METHOD_NOT_ALLOWED; }
|
|
81
|
-
constructor(internalMessage, options) {
|
|
82
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.METHOD_NOT_ALLOWED, internalMessage, options));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.MethodNotAllowedError = MethodNotAllowedError;
|
|
86
|
-
class NotAcceptableError extends (0, default_error_js_1.DefaultErrorBase)(common_1.NotAcceptableException) {
|
|
87
|
-
static { this.defaultStatusCode = common_1.HttpStatus.NOT_ACCEPTABLE; }
|
|
88
|
-
constructor(internalMessage, options) {
|
|
89
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.NOT_ACCEPTABLE, internalMessage, options));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.NotAcceptableError = NotAcceptableError;
|
|
93
|
-
class GoneError extends (0, default_error_js_1.DefaultErrorBase)(common_1.GoneException) {
|
|
94
|
-
static { this.defaultStatusCode = common_1.HttpStatus.GONE; }
|
|
95
|
-
constructor(internalMessage, options) {
|
|
96
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.GONE, internalMessage, options));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.GoneError = GoneError;
|
|
100
|
-
class UnsupportedMediaTypeError extends (0, default_error_js_1.DefaultErrorBase)(common_1.UnsupportedMediaTypeException) {
|
|
101
|
-
static { this.defaultStatusCode = common_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE; }
|
|
102
|
-
constructor(internalMessage, options) {
|
|
103
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.UNSUPPORTED_MEDIA_TYPE, internalMessage, options));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
|
|
107
|
-
class UnprocessableEntityError extends (0, default_error_js_1.DefaultErrorBase)(common_1.UnprocessableEntityException) {
|
|
108
|
-
static { this.defaultStatusCode = common_1.HttpStatus.UNPROCESSABLE_ENTITY; }
|
|
109
|
-
constructor(internalMessage, options) {
|
|
110
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.UNPROCESSABLE_ENTITY, internalMessage, options));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
114
|
-
class TooManyRequestsError extends (0, default_error_js_1.DefaultErrorBase)(common_1.HttpException) {
|
|
115
|
-
static { this.defaultStatusCode = common_1.HttpStatus.TOO_MANY_REQUESTS; }
|
|
116
|
-
constructor(internalMessage, options) {
|
|
117
|
-
super(...buildArgsHttpException(error_enum_js_1.ErrorsEnum.TOO_MANY_REQUESTS, internalMessage, options, common_1.HttpStatus.TOO_MANY_REQUESTS));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.TooManyRequestsError = TooManyRequestsError;
|
|
121
|
-
class NotImplementedError extends (0, default_error_js_1.DefaultErrorBase)(common_1.NotImplementedException) {
|
|
122
|
-
static { this.defaultStatusCode = common_1.HttpStatus.NOT_IMPLEMENTED; }
|
|
123
|
-
constructor(internalMessage, options) {
|
|
124
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.NOT_IMPLEMENTED, internalMessage, options));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.NotImplementedError = NotImplementedError;
|
|
128
|
-
class BadGatewayError extends (0, default_error_js_1.DefaultErrorBase)(common_1.BadGatewayException) {
|
|
129
|
-
static { this.defaultStatusCode = common_1.HttpStatus.BAD_GATEWAY; }
|
|
130
|
-
constructor(internalMessage, options) {
|
|
131
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.BAD_GATEWAY, internalMessage, options));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.BadGatewayError = BadGatewayError;
|
|
135
|
-
class ServiceUnavailableError extends (0, default_error_js_1.DefaultErrorBase)(common_1.ServiceUnavailableException) {
|
|
136
|
-
static { this.defaultStatusCode = common_1.HttpStatus.SERVICE_UNAVAILABLE; }
|
|
137
|
-
constructor(internalMessage, options) {
|
|
138
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.SERVICE_UNAVAILABLE, internalMessage, options));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
142
|
-
class GatewayTimeoutError extends (0, default_error_js_1.DefaultErrorBase)(common_1.GatewayTimeoutException) {
|
|
143
|
-
static { this.defaultStatusCode = common_1.HttpStatus.GATEWAY_TIMEOUT; }
|
|
144
|
-
constructor(internalMessage, options) {
|
|
145
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.GATEWAY_TIMEOUT, internalMessage, options));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
exports.GatewayTimeoutError = GatewayTimeoutError;
|
|
149
|
-
class AdditionalVerificationNeededError extends (0, default_error_js_1.DefaultErrorBase)(common_1.HttpException) {
|
|
150
|
-
static { this.defaultStatusCode = axios_1.HttpStatusCode.UnavailableForLegalReasons; }
|
|
151
|
-
constructor(internalMessage, options) {
|
|
152
|
-
super(...buildArgsHttpException(error_enum_js_1.ErrorsEnum.UNAVAILABLE_FOR_LEGAL_REASONS, internalMessage, options, AdditionalVerificationNeededError.defaultStatusCode));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.AdditionalVerificationNeededError = AdditionalVerificationNeededError;
|
|
156
|
-
class LoginError extends (0, default_error_js_1.DefaultErrorBase)(common_1.UnauthorizedException) {
|
|
157
|
-
static { this.defaultStatusCode = common_1.HttpStatus.UNAUTHORIZED; }
|
|
158
|
-
constructor(internalMessage, options) {
|
|
159
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.BAD_LOGIN, internalMessage, options));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
exports.LoginError = LoginError;
|
|
163
|
-
class InputValidationError extends (0, default_error_js_1.DefaultErrorBase)(common_1.BadRequestException) {
|
|
164
|
-
static { this.defaultStatusCode = common_1.HttpStatus.BAD_REQUEST; }
|
|
165
|
-
constructor(internalMessage, options) {
|
|
166
|
-
super(...buildArgs(error_enum_js_1.ErrorsEnum.INVALID_VALUE, internalMessage, options));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.InputValidationError = InputValidationError;
|
|
170
|
-
//# sourceMappingURL=error.class.js.map
|
package/src/error.class.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.class.js","sourceRoot":"","sources":["error.class.ts"],"names":[],"mappings":";;;AAEA,2CAmBwB;AACxB,mDAA6C;AAC7C,yDAAgF;AAChF,iCAAuC;AAIvC,SAAS,SAAS,CAChB,SAAqB,EACrB,eAAwB,EACxB,OAAkC;IAOlC,MAAM,EAAE,KAAK,EAAE,WAAW,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AC1E,CAAC;;AANH,oDAOC"}
|
package/src/error.class.ts
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BadRequestException,
|
|
5
|
-
UnauthorizedException,
|
|
6
|
-
ForbiddenException,
|
|
7
|
-
NotFoundException,
|
|
8
|
-
ConflictException,
|
|
9
|
-
InternalServerErrorException,
|
|
10
|
-
HttpException,
|
|
11
|
-
HttpStatus,
|
|
12
|
-
HttpExceptionOptions,
|
|
13
|
-
MethodNotAllowedException,
|
|
14
|
-
NotAcceptableException,
|
|
15
|
-
GoneException,
|
|
16
|
-
UnsupportedMediaTypeException,
|
|
17
|
-
UnprocessableEntityException,
|
|
18
|
-
NotImplementedException,
|
|
19
|
-
BadGatewayException,
|
|
20
|
-
ServiceUnavailableException,
|
|
21
|
-
GatewayTimeoutException,
|
|
22
|
-
} from '@nestjs/common';
|
|
23
|
-
import { ErrorsEnum } from './error.enum.js';
|
|
24
|
-
import { DefaultErrorBase, IDefaultErrorBaseOptions } from './default.error.js';
|
|
25
|
-
import { HttpStatusCode } from 'axios';
|
|
26
|
-
|
|
27
|
-
type AxiosHttpStatusCode = (typeof HttpStatusCode)[keyof typeof HttpStatusCode];
|
|
28
|
-
|
|
29
|
-
function buildArgs(
|
|
30
|
-
errorName: ErrorsEnum,
|
|
31
|
-
internalMessage?: string,
|
|
32
|
-
options?: IDefaultErrorBaseOptions,
|
|
33
|
-
): [
|
|
34
|
-
string,
|
|
35
|
-
IDefaultErrorBaseOptions,
|
|
36
|
-
string | object | any,
|
|
37
|
-
string | HttpExceptionOptions,
|
|
38
|
-
] {
|
|
39
|
-
const { cause, description, response, ...restOptions } = options ?? {};
|
|
40
|
-
return [
|
|
41
|
-
internalMessage ? `${errorName}: ${internalMessage}` : errorName,
|
|
42
|
-
{ ...(restOptions ?? {}), description },
|
|
43
|
-
response ?? {},
|
|
44
|
-
{
|
|
45
|
-
cause,
|
|
46
|
-
description,
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function buildArgsHttpException(
|
|
52
|
-
errorName: ErrorsEnum,
|
|
53
|
-
internalMessage?: string,
|
|
54
|
-
options?: IDefaultErrorBaseOptions,
|
|
55
|
-
errorCode?: HttpStatus | AxiosHttpStatusCode,
|
|
56
|
-
): [
|
|
57
|
-
string,
|
|
58
|
-
IDefaultErrorBaseOptions,
|
|
59
|
-
string | object | any,
|
|
60
|
-
number,
|
|
61
|
-
HttpExceptionOptions,
|
|
62
|
-
] {
|
|
63
|
-
const args = buildArgs(errorName, internalMessage, options);
|
|
64
|
-
return [
|
|
65
|
-
args[0],
|
|
66
|
-
args[1],
|
|
67
|
-
args[2],
|
|
68
|
-
errorCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
|
|
69
|
-
typeof args[3] === 'string' ? { description: args[3] } : args[3],
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Use when the request could not be understood or was missing required parameters.
|
|
75
|
-
*/
|
|
76
|
-
export class BadRequestError extends DefaultErrorBase(BadRequestException) {
|
|
77
|
-
static defaultStatusCode = HttpStatus.BAD_REQUEST;
|
|
78
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
79
|
-
super(...buildArgs(ErrorsEnum.BAD_REQUEST, internalMessage, options));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Use when authentication failed or the user does not have permissions for the desired action.
|
|
85
|
-
*/
|
|
86
|
-
export class UnauthorizedError extends DefaultErrorBase(UnauthorizedException) {
|
|
87
|
-
static defaultStatusCode = HttpStatus.UNAUTHORIZED;
|
|
88
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
89
|
-
super(...buildArgs(ErrorsEnum.UNAUTHORIZED, internalMessage, options));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Use when the authenticated user does not have access to the requested resource.
|
|
95
|
-
*/
|
|
96
|
-
export class ForbiddenError extends DefaultErrorBase(ForbiddenException) {
|
|
97
|
-
static defaultStatusCode = HttpStatus.FORBIDDEN;
|
|
98
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
99
|
-
super(...buildArgs(ErrorsEnum.FORBIDDEN, internalMessage, options));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Use when the requested resource could not be found.
|
|
105
|
-
*/
|
|
106
|
-
export class NotFoundError extends DefaultErrorBase(NotFoundException) {
|
|
107
|
-
static defaultStatusCode = HttpStatus.NOT_FOUND;
|
|
108
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
109
|
-
super(...buildArgs(ErrorsEnum.NOT_FOUND, internalMessage, options));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Use when the request could not be completed due to a conflict with the current state of the target resource.
|
|
115
|
-
*/
|
|
116
|
-
export class ConflictError extends DefaultErrorBase(ConflictException) {
|
|
117
|
-
static defaultStatusCode = HttpStatus.CONFLICT;
|
|
118
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
119
|
-
super(...buildArgs(ErrorsEnum.CONFLICT, internalMessage, options));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Use when an unexpected error occurred on the server side.
|
|
125
|
-
*/
|
|
126
|
-
export class InternalServerError extends DefaultErrorBase(
|
|
127
|
-
InternalServerErrorException,
|
|
128
|
-
) {
|
|
129
|
-
static defaultStatusCode = HttpStatus.INTERNAL_SERVER_ERROR;
|
|
130
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
131
|
-
super(
|
|
132
|
-
...buildArgs(ErrorsEnum.INTERNAL_SERVER_ERROR, internalMessage, options),
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// The following classes are based on HTTP statuses not covered by NestJS built-in exceptions
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Reserved for future use; its utilization is not common.
|
|
141
|
-
*/
|
|
142
|
-
export class PaymentRequiredError extends DefaultErrorBase(HttpException) {
|
|
143
|
-
static defaultStatusCode = HttpStatus.PAYMENT_REQUIRED;
|
|
144
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
145
|
-
super(
|
|
146
|
-
...buildArgsHttpException(
|
|
147
|
-
ErrorsEnum.PAYMENT_REQUIRED,
|
|
148
|
-
internalMessage,
|
|
149
|
-
options,
|
|
150
|
-
PaymentRequiredError.defaultStatusCode,
|
|
151
|
-
),
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Use when an unsupported HTTP method was used for the request.
|
|
158
|
-
*/
|
|
159
|
-
export class MethodNotAllowedError extends DefaultErrorBase(
|
|
160
|
-
MethodNotAllowedException,
|
|
161
|
-
) {
|
|
162
|
-
static defaultStatusCode = HttpStatus.METHOD_NOT_ALLOWED;
|
|
163
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
164
|
-
super(
|
|
165
|
-
...buildArgs(ErrorsEnum.METHOD_NOT_ALLOWED, internalMessage, options),
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Use when the server cannot produce a response matching the list of acceptable values defined in the request's headers.
|
|
172
|
-
*/
|
|
173
|
-
export class NotAcceptableError extends DefaultErrorBase(
|
|
174
|
-
NotAcceptableException,
|
|
175
|
-
) {
|
|
176
|
-
static defaultStatusCode = HttpStatus.NOT_ACCEPTABLE;
|
|
177
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
178
|
-
super(...buildArgs(ErrorsEnum.NOT_ACCEPTABLE, internalMessage, options));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Use when the requested resource has been permanently deleted and will not be available again.
|
|
184
|
-
*/
|
|
185
|
-
export class GoneError extends DefaultErrorBase(GoneException) {
|
|
186
|
-
static defaultStatusCode = HttpStatus.GONE;
|
|
187
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
188
|
-
super(...buildArgs(ErrorsEnum.GONE, internalMessage, options));
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Use when the request entity has a media type which the server or resource does not support.
|
|
194
|
-
*/
|
|
195
|
-
export class UnsupportedMediaTypeError extends DefaultErrorBase(
|
|
196
|
-
UnsupportedMediaTypeException,
|
|
197
|
-
) {
|
|
198
|
-
static defaultStatusCode = HttpStatus.UNSUPPORTED_MEDIA_TYPE;
|
|
199
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
200
|
-
super(
|
|
201
|
-
...buildArgs(ErrorsEnum.UNSUPPORTED_MEDIA_TYPE, internalMessage, options),
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Use when the server understands the content type of the request entity, but was unable to process the contained instructions.
|
|
208
|
-
*/
|
|
209
|
-
export class UnprocessableEntityError extends DefaultErrorBase(
|
|
210
|
-
UnprocessableEntityException,
|
|
211
|
-
) {
|
|
212
|
-
static defaultStatusCode = HttpStatus.UNPROCESSABLE_ENTITY;
|
|
213
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
214
|
-
super(
|
|
215
|
-
...buildArgs(ErrorsEnum.UNPROCESSABLE_ENTITY, internalMessage, options),
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Use when the user has sent too many requests in a given amount of time ("rate limiting").
|
|
222
|
-
*/
|
|
223
|
-
export class TooManyRequestsError extends DefaultErrorBase(HttpException) {
|
|
224
|
-
static defaultStatusCode = HttpStatus.TOO_MANY_REQUESTS;
|
|
225
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
226
|
-
super(
|
|
227
|
-
...buildArgsHttpException(
|
|
228
|
-
ErrorsEnum.TOO_MANY_REQUESTS,
|
|
229
|
-
internalMessage,
|
|
230
|
-
options,
|
|
231
|
-
HttpStatus.TOO_MANY_REQUESTS,
|
|
232
|
-
),
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Use when the server does not support the functionality required to fulfill the request.
|
|
239
|
-
*/
|
|
240
|
-
export class NotImplementedError extends DefaultErrorBase(
|
|
241
|
-
NotImplementedException,
|
|
242
|
-
) {
|
|
243
|
-
static defaultStatusCode = HttpStatus.NOT_IMPLEMENTED;
|
|
244
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
245
|
-
super(...buildArgs(ErrorsEnum.NOT_IMPLEMENTED, internalMessage, options));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Use when the server, while acting as a gateway or proxy, received an invalid response from the upstream server.
|
|
251
|
-
*/
|
|
252
|
-
export class BadGatewayError extends DefaultErrorBase(BadGatewayException) {
|
|
253
|
-
static defaultStatusCode = HttpStatus.BAD_GATEWAY;
|
|
254
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
255
|
-
super(...buildArgs(ErrorsEnum.BAD_GATEWAY, internalMessage, options));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Use when the server is currently unavailable (because it is overloaded or down for maintenance).
|
|
261
|
-
*/
|
|
262
|
-
export class ServiceUnavailableError extends DefaultErrorBase(
|
|
263
|
-
ServiceUnavailableException,
|
|
264
|
-
) {
|
|
265
|
-
static defaultStatusCode = HttpStatus.SERVICE_UNAVAILABLE;
|
|
266
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
267
|
-
super(
|
|
268
|
-
...buildArgs(ErrorsEnum.SERVICE_UNAVAILABLE, internalMessage, options),
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Use when the server, while acting as a gateway or proxy, did not receive a timely response from the upstream server or some other auxiliary server.
|
|
275
|
-
*/
|
|
276
|
-
export class GatewayTimeoutError extends DefaultErrorBase(
|
|
277
|
-
GatewayTimeoutException,
|
|
278
|
-
) {
|
|
279
|
-
static defaultStatusCode = HttpStatus.GATEWAY_TIMEOUT;
|
|
280
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
281
|
-
super(...buildArgs(ErrorsEnum.GATEWAY_TIMEOUT, internalMessage, options));
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Custom
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
export class AdditionalVerificationNeededError extends DefaultErrorBase(
|
|
290
|
-
HttpException,
|
|
291
|
-
) {
|
|
292
|
-
static defaultStatusCode: any = HttpStatusCode.UnavailableForLegalReasons;
|
|
293
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
294
|
-
super(
|
|
295
|
-
...buildArgsHttpException(
|
|
296
|
-
ErrorsEnum.UNAVAILABLE_FOR_LEGAL_REASONS,
|
|
297
|
-
internalMessage,
|
|
298
|
-
options,
|
|
299
|
-
AdditionalVerificationNeededError.defaultStatusCode,
|
|
300
|
-
),
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export class LoginError extends DefaultErrorBase(UnauthorizedException) {
|
|
306
|
-
static defaultStatusCode = HttpStatus.UNAUTHORIZED;
|
|
307
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
308
|
-
super(...buildArgs(ErrorsEnum.BAD_LOGIN, internalMessage, options));
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export class InputValidationError extends DefaultErrorBase(
|
|
313
|
-
BadRequestException,
|
|
314
|
-
) {
|
|
315
|
-
static defaultStatusCode = HttpStatus.BAD_REQUEST;
|
|
316
|
-
constructor(internalMessage?: string, options?: IDefaultErrorBaseOptions) {
|
|
317
|
-
super(...buildArgs(ErrorsEnum.INVALID_VALUE, internalMessage, options));
|
|
318
|
-
}
|
|
319
|
-
}
|
package/src/error.enum.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare enum ErrorsEnum {
|
|
2
|
-
BAD_REQUEST = "Bad request",
|
|
3
|
-
INVALID_VALUE = "Invalid value",
|
|
4
|
-
UNAUTHORIZED = "Unauthorized",
|
|
5
|
-
BAD_LOGIN = "Bad login",
|
|
6
|
-
PAYMENT_REQUIRED = "Payment required",
|
|
7
|
-
FORBIDDEN = "Forbidden",
|
|
8
|
-
FORBIDDEN_RESOURCE = "Forbidden resource",
|
|
9
|
-
NOT_FOUND = "Not found",
|
|
10
|
-
METHOD_NOT_ALLOWED = "Method not allowed",
|
|
11
|
-
NOT_ACCEPTABLE = "Not acceptable",
|
|
12
|
-
CONFLICT = "Conflict",
|
|
13
|
-
GONE = "Gone",
|
|
14
|
-
UNSUPPORTED_MEDIA_TYPE = "Unsupported media type",
|
|
15
|
-
UNPROCESSABLE_ENTITY = "Unprocessable entity",
|
|
16
|
-
UNAVAILABLE_FOR_LEGAL_REASONS = "Unavailable for legal reasons",
|
|
17
|
-
TOO_MANY_REQUESTS = "Too many requests",
|
|
18
|
-
INTERNAL_SERVER_ERROR = "Internal server error",
|
|
19
|
-
NOT_IMPLEMENTED = "Not implemented",
|
|
20
|
-
BAD_GATEWAY = "Bad gateway",
|
|
21
|
-
SERVICE_UNAVAILABLE = "Service unavailable",
|
|
22
|
-
GATEWAY_TIMEOUT = "Gateway timeout"
|
|
23
|
-
}
|
|
24
|
-
export declare const getHttpStatusNameByCode: (code: number) => string;
|
|
25
|
-
export declare enum ExceptionContextEnum {
|
|
26
|
-
DATABASE = "DatabaseException",
|
|
27
|
-
HTTP = "HttpException",
|
|
28
|
-
SYSTEM = "SystemException"
|
|
29
|
-
}
|
package/src/error.enum.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExceptionContextEnum = exports.getHttpStatusNameByCode = exports.ErrorsEnum = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
var ErrorsEnum;
|
|
6
|
-
(function (ErrorsEnum) {
|
|
7
|
-
ErrorsEnum["BAD_REQUEST"] = "Bad request";
|
|
8
|
-
ErrorsEnum["INVALID_VALUE"] = "Invalid value";
|
|
9
|
-
ErrorsEnum["UNAUTHORIZED"] = "Unauthorized";
|
|
10
|
-
ErrorsEnum["BAD_LOGIN"] = "Bad login";
|
|
11
|
-
ErrorsEnum["PAYMENT_REQUIRED"] = "Payment required";
|
|
12
|
-
ErrorsEnum["FORBIDDEN"] = "Forbidden";
|
|
13
|
-
ErrorsEnum["FORBIDDEN_RESOURCE"] = "Forbidden resource";
|
|
14
|
-
ErrorsEnum["NOT_FOUND"] = "Not found";
|
|
15
|
-
ErrorsEnum["METHOD_NOT_ALLOWED"] = "Method not allowed";
|
|
16
|
-
ErrorsEnum["NOT_ACCEPTABLE"] = "Not acceptable";
|
|
17
|
-
ErrorsEnum["CONFLICT"] = "Conflict";
|
|
18
|
-
ErrorsEnum["GONE"] = "Gone";
|
|
19
|
-
ErrorsEnum["UNSUPPORTED_MEDIA_TYPE"] = "Unsupported media type";
|
|
20
|
-
ErrorsEnum["UNPROCESSABLE_ENTITY"] = "Unprocessable entity";
|
|
21
|
-
ErrorsEnum["UNAVAILABLE_FOR_LEGAL_REASONS"] = "Unavailable for legal reasons";
|
|
22
|
-
ErrorsEnum["TOO_MANY_REQUESTS"] = "Too many requests";
|
|
23
|
-
ErrorsEnum["INTERNAL_SERVER_ERROR"] = "Internal server error";
|
|
24
|
-
ErrorsEnum["NOT_IMPLEMENTED"] = "Not implemented";
|
|
25
|
-
ErrorsEnum["BAD_GATEWAY"] = "Bad gateway";
|
|
26
|
-
ErrorsEnum["SERVICE_UNAVAILABLE"] = "Service unavailable";
|
|
27
|
-
ErrorsEnum["GATEWAY_TIMEOUT"] = "Gateway timeout";
|
|
28
|
-
})(ErrorsEnum || (exports.ErrorsEnum = ErrorsEnum = {}));
|
|
29
|
-
const getHttpStatusNameByCode = (code) => {
|
|
30
|
-
const httpStatusEnumName = Object.entries(common_1.HttpStatus).find(([, value]) => value === code)?.[0];
|
|
31
|
-
const enumValue = ErrorsEnum[httpStatusEnumName];
|
|
32
|
-
return enumValue ?? 'Unknown';
|
|
33
|
-
};
|
|
34
|
-
exports.getHttpStatusNameByCode = getHttpStatusNameByCode;
|
|
35
|
-
var ExceptionContextEnum;
|
|
36
|
-
(function (ExceptionContextEnum) {
|
|
37
|
-
ExceptionContextEnum["DATABASE"] = "DatabaseException";
|
|
38
|
-
ExceptionContextEnum["HTTP"] = "HttpException";
|
|
39
|
-
ExceptionContextEnum["SYSTEM"] = "SystemException";
|
|
40
|
-
})(ExceptionContextEnum || (exports.ExceptionContextEnum = ExceptionContextEnum = {}));
|
|
41
|
-
//# sourceMappingURL=error.enum.js.map
|