@nathapp/nestjs-common 3.2.0 → 3.2.1
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/dist/exception/default-i18n-validation-exception.filter.d.ts +1 -1
- package/dist/exception/default-i18n-validation-exception.filter.js +6 -6
- package/dist/exception/default-i18n-validation-exception.filter.js.map +1 -1
- package/dist/exception/{captcha.exception.d.ts → exceptions/captcha.exception.d.ts} +1 -1
- package/dist/exception/{captcha.exception.js → exceptions/captcha.exception.js} +3 -3
- package/dist/exception/exceptions/captcha.exception.js.map +1 -0
- package/dist/exception/exceptions/index.d.ts +4 -2
- package/dist/exception/exceptions/index.js +10 -5
- package/dist/exception/exceptions/index.js.map +1 -1
- package/dist/exception/{two-factor.exception.d.ts → exceptions/two-factor.exception.d.ts} +1 -1
- package/dist/exception/{two-factor.exception.js → exceptions/two-factor.exception.js} +4 -4
- package/dist/exception/exceptions/two-factor.exception.js.map +1 -0
- package/dist/exception/global-exception.filter.js +26 -10
- package/dist/exception/global-exception.filter.js.map +1 -1
- package/dist/exception/handler/app-exception.handler.js +17 -4
- package/dist/exception/handler/app-exception.handler.js.map +1 -1
- package/dist/exception/handler/index.d.ts +0 -1
- package/dist/exception/handler/index.js +1 -5
- package/dist/exception/handler/index.js.map +1 -1
- package/dist/exception/index.d.ts +2 -4
- package/dist/exception/index.js +5 -7
- package/dist/exception/index.js.map +1 -1
- package/dist/exception/user-not-found.exception.d.ts +3 -3
- package/dist/exception/user-not-found.exception.js +5 -4
- package/dist/exception/user-not-found.exception.js.map +1 -1
- package/package.json +1 -1
- package/dist/exception/captcha.exception.js.map +0 -1
- package/dist/exception/handler/username-not-found.handler.d.ts +0 -6
- package/dist/exception/handler/username-not-found.handler.js +0 -28
- package/dist/exception/handler/username-not-found.handler.js.map +0 -1
- package/dist/exception/two-factor.exception.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I18nService, I18nValidationError, I18nValidationException } from 'nestjs-i18n';
|
|
2
2
|
import { I18nValidationExceptionFilter, I18nValidationExceptionFilterOptions } from './i18n-validation-exception.filter';
|
|
3
3
|
import { ArgumentsHost } from '@nestjs/common';
|
|
4
|
-
export declare const defaultResponseFormatter: (
|
|
4
|
+
export declare const defaultResponseFormatter: (_hostname: ArgumentsHost, _exc: I18nValidationException, formattedErrors: string[] | I18nValidationError[] | object) => {
|
|
5
5
|
ret: number;
|
|
6
6
|
message: string;
|
|
7
7
|
errors: Record<string, any>;
|
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultI18nValidationExceptionFilter = exports.defaultResponseFormatter = void 0;
|
|
4
4
|
const i18n_validation_exception_filter_1 = require("./i18n-validation-exception.filter");
|
|
5
|
-
const
|
|
5
|
+
const exceptions_1 = require("./exceptions");
|
|
6
6
|
const findFirstError = (error) => {
|
|
7
7
|
if (error.children && error.children.length > 0) {
|
|
8
8
|
return findFirstError(error.children[0]);
|
|
9
9
|
}
|
|
10
10
|
return error;
|
|
11
11
|
};
|
|
12
|
-
const defaultResponseFormatter = (
|
|
12
|
+
const defaultResponseFormatter = (_hostname, _exc, formattedErrors) => {
|
|
13
13
|
if (!Array.isArray(formattedErrors)) {
|
|
14
|
-
throw new
|
|
14
|
+
throw new exceptions_1.ValidationAppException();
|
|
15
15
|
}
|
|
16
16
|
let message = '';
|
|
17
17
|
const errors = {};
|
|
18
|
-
formattedErrors.
|
|
18
|
+
formattedErrors.forEach((error, index) => {
|
|
19
19
|
if (typeof error === 'string') {
|
|
20
|
-
if (index
|
|
20
|
+
if (index === 0) {
|
|
21
21
|
message = error;
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return;
|
|
24
24
|
}
|
|
25
25
|
const firstError = findFirstError(error);
|
|
26
26
|
if (firstError === null || firstError === void 0 ? void 0 : firstError.constraints) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-i18n-validation-exception.filter.js","sourceRoot":"","sources":["../../lib/exception/default-i18n-validation-exception.filter.ts"],"names":[],"mappings":";;;AAKA,yFAG4C;AAE5C,
|
|
1
|
+
{"version":3,"file":"default-i18n-validation-exception.filter.js","sourceRoot":"","sources":["../../lib/exception/default-i18n-validation-exception.filter.ts"],"names":[],"mappings":";;;AAKA,yFAG4C;AAE5C,6CAAsD;AAEtD,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAuB,EAAE;IACzE,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEK,MAAM,wBAAwB,GAAG,CACtC,SAAwB,EACxB,IAA6B,EAC7B,eAA0D,EAC1D,EAAE;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;QAGpC,MAAM,IAAI,mCAAsB,EAAE,CAAC;IACrC,CAAC;IAED,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,eAAe,CAAC,OAAO,CAAC,CAAC,KAAmC,EAAE,KAAa,EAAE,EAAE;QAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBAChB,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,EAAE,CAAC;YAC5B,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAEzE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE;gBACpF,OAAO,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,EAAE,CAAC,CAAC;QACP,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,wBAAwB,4BAoCnC;AAEF,MAAa,oCAAqC,SAAQ,gEAA6B;IACrF,YACE,WAAwB,EACxB,UAAgD;QAC9C,cAAc,EAAE,IAAI;KACrB;QAED,KAAK,CAAC,WAAW,EAAE;YACjB,qBAAqB,EAAE,gCAAwB;YAC/C,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF;AAZD,oFAYC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CaptchaException = void 0;
|
|
4
|
-
const app_exception_code_enum_1 = require("
|
|
5
|
-
const app_exception_1 = require("
|
|
4
|
+
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
5
|
+
const app_exception_1 = require("../app.exception");
|
|
6
6
|
class CaptchaException extends app_exception_1.AppException {
|
|
7
7
|
constructor(args, prefix) {
|
|
8
|
-
super(app_exception_code_enum_1.CommonExceptionCode.CAPTCHA_ERROR, args, prefix);
|
|
8
|
+
super(app_exception_code_enum_1.CommonExceptionCode.CAPTCHA_ERROR, args, prefix, 403);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.CaptchaException = CaptchaException;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captcha.exception.js","sourceRoot":"","sources":["../../../lib/exception/exceptions/captcha.exception.ts"],"names":[],"mappings":";;;AAAA,wEAAiE;AACjE,oDAAgD;AAEhD,MAAa,gBAAiB,SAAQ,4BAAY;IAChD,YAAY,IAAU,EAAE,MAAe;QACrC,KAAK,CAAC,6CAAmB,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9D,CAAC;CACF;AAJD,4CAIC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { AuthException } from "./auth.exception";
|
|
2
|
+
export { CaptchaException } from "./captcha.exception";
|
|
2
3
|
export { ForbiddenAppException } from "./forbidden-app.exception";
|
|
4
|
+
export { InternalAppException } from "./internal-app.exception";
|
|
3
5
|
export { NotFoundAppException } from "./not-found-app.exception";
|
|
4
|
-
export { ValidationAppException } from "./validation-app.exception";
|
|
5
6
|
export { ThrottleAppException } from "./throttle-app.exception";
|
|
6
|
-
export {
|
|
7
|
+
export { TwoFactorInvalidException, TwoFactorRequiredException } from "./two-factor.exception";
|
|
8
|
+
export { ValidationAppException } from "./validation-app.exception";
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ValidationAppException = exports.TwoFactorRequiredException = exports.TwoFactorInvalidException = exports.ThrottleAppException = exports.NotFoundAppException = exports.InternalAppException = exports.ForbiddenAppException = exports.CaptchaException = exports.AuthException = void 0;
|
|
4
4
|
var auth_exception_1 = require("./auth.exception");
|
|
5
5
|
Object.defineProperty(exports, "AuthException", { enumerable: true, get: function () { return auth_exception_1.AuthException; } });
|
|
6
|
+
var captcha_exception_1 = require("./captcha.exception");
|
|
7
|
+
Object.defineProperty(exports, "CaptchaException", { enumerable: true, get: function () { return captcha_exception_1.CaptchaException; } });
|
|
6
8
|
var forbidden_app_exception_1 = require("./forbidden-app.exception");
|
|
7
9
|
Object.defineProperty(exports, "ForbiddenAppException", { enumerable: true, get: function () { return forbidden_app_exception_1.ForbiddenAppException; } });
|
|
10
|
+
var internal_app_exception_1 = require("./internal-app.exception");
|
|
11
|
+
Object.defineProperty(exports, "InternalAppException", { enumerable: true, get: function () { return internal_app_exception_1.InternalAppException; } });
|
|
8
12
|
var not_found_app_exception_1 = require("./not-found-app.exception");
|
|
9
13
|
Object.defineProperty(exports, "NotFoundAppException", { enumerable: true, get: function () { return not_found_app_exception_1.NotFoundAppException; } });
|
|
10
|
-
var validation_app_exception_1 = require("./validation-app.exception");
|
|
11
|
-
Object.defineProperty(exports, "ValidationAppException", { enumerable: true, get: function () { return validation_app_exception_1.ValidationAppException; } });
|
|
12
14
|
var throttle_app_exception_1 = require("./throttle-app.exception");
|
|
13
15
|
Object.defineProperty(exports, "ThrottleAppException", { enumerable: true, get: function () { return throttle_app_exception_1.ThrottleAppException; } });
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
+
var two_factor_exception_1 = require("./two-factor.exception");
|
|
17
|
+
Object.defineProperty(exports, "TwoFactorInvalidException", { enumerable: true, get: function () { return two_factor_exception_1.TwoFactorInvalidException; } });
|
|
18
|
+
Object.defineProperty(exports, "TwoFactorRequiredException", { enumerable: true, get: function () { return two_factor_exception_1.TwoFactorRequiredException; } });
|
|
19
|
+
var validation_app_exception_1 = require("./validation-app.exception");
|
|
20
|
+
Object.defineProperty(exports, "ValidationAppException", { enumerable: true, get: function () { return validation_app_exception_1.ValidationAppException; } });
|
|
16
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/exception/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/exception/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,+DAA+F;AAAtF,iIAAA,yBAAyB,OAAA;AAAE,kIAAA,0BAA0B,OAAA;AAC9D,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TwoFactorInvalidException = exports.TwoFactorRequiredException = void 0;
|
|
4
|
-
const app_exception_code_enum_1 = require("
|
|
5
|
-
const app_exception_1 = require("
|
|
4
|
+
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
5
|
+
const app_exception_1 = require("../app.exception");
|
|
6
6
|
class TwoFactorRequiredException extends app_exception_1.AppException {
|
|
7
7
|
constructor() {
|
|
8
|
-
super(app_exception_code_enum_1.CommonExceptionCode.TWO_FACTOR_REQUIRED);
|
|
8
|
+
super(app_exception_code_enum_1.CommonExceptionCode.TWO_FACTOR_REQUIRED, undefined, undefined, 403);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.TwoFactorRequiredException = TwoFactorRequiredException;
|
|
12
12
|
class TwoFactorInvalidException extends app_exception_1.AppException {
|
|
13
13
|
constructor() {
|
|
14
|
-
super(app_exception_code_enum_1.CommonExceptionCode.TWO_FACTOR_INVALID);
|
|
14
|
+
super(app_exception_code_enum_1.CommonExceptionCode.TWO_FACTOR_INVALID, undefined, undefined, 403);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.TwoFactorInvalidException = TwoFactorInvalidException;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor.exception.js","sourceRoot":"","sources":["../../../lib/exception/exceptions/two-factor.exception.ts"],"names":[],"mappings":";;;AAAA,wEAAiE;AACjE,oDAAgD;AAEhD,MAAa,0BAA2B,SAAQ,4BAAY;IAC1D;QACE,KAAK,CAAC,6CAAmB,CAAC,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC;CACF;AAJD,gEAIC;AAED,MAAa,yBAA0B,SAAQ,4BAAY;IACzD;QACE,KAAK,CAAC,6CAAmB,CAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF;AAJD,8DAIC"}
|
|
@@ -20,6 +20,8 @@ const core_1 = require("@nestjs/core");
|
|
|
20
20
|
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
21
21
|
const handler_1 = require("./handler");
|
|
22
22
|
const exception_constants_1 = require("./exception.constants");
|
|
23
|
+
const app_exception_code_enum_1 = require("./app-exception-code.enum");
|
|
24
|
+
const app_exception_1 = require("./app.exception");
|
|
23
25
|
let GlobalExceptionsFilter = GlobalExceptionsFilter_1 = class GlobalExceptionsFilter {
|
|
24
26
|
constructor(httpAdapterHost, i18nService, injectedHandlers) {
|
|
25
27
|
this.httpAdapterHost = httpAdapterHost;
|
|
@@ -42,6 +44,7 @@ let GlobalExceptionsFilter = GlobalExceptionsFilter_1 = class GlobalExceptionsFi
|
|
|
42
44
|
GlobalExceptionsFilter_1.customHandlers.clear();
|
|
43
45
|
}
|
|
44
46
|
async catch(exception, host) {
|
|
47
|
+
var _a;
|
|
45
48
|
const { httpAdapter } = this.httpAdapterHost;
|
|
46
49
|
const ctx = host.switchToHttp();
|
|
47
50
|
const response = ctx.getResponse();
|
|
@@ -54,18 +57,34 @@ let GlobalExceptionsFilter = GlobalExceptionsFilter_1 = class GlobalExceptionsFi
|
|
|
54
57
|
};
|
|
55
58
|
let result;
|
|
56
59
|
for (const handler of this.handlers) {
|
|
60
|
+
let matched = false;
|
|
57
61
|
try {
|
|
58
|
-
|
|
62
|
+
matched = handler.canHandle(exception);
|
|
63
|
+
}
|
|
64
|
+
catch (canHandleError) {
|
|
65
|
+
this.logger.error(`Exception handler ${handler.constructor.name} canHandle failed: ${canHandleError}`, canHandleError instanceof Error ? canHandleError.stack : undefined);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (matched) {
|
|
69
|
+
try {
|
|
59
70
|
result = await handler.handle(exception, context);
|
|
60
|
-
break;
|
|
61
71
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
catch (handleError) {
|
|
73
|
+
this.logger.error(`Exception handler ${handler.constructor.name} handle failed: ${handleError}`, handleError instanceof Error ? handleError.stack : undefined);
|
|
74
|
+
if (exception instanceof app_exception_1.AppException) {
|
|
75
|
+
result = {
|
|
76
|
+
httpStatus: (_a = exception.httpStatus) !== null && _a !== void 0 ? _a : 500,
|
|
77
|
+
errorCode: exception.code,
|
|
78
|
+
message: await this.translate(exception.code, lang, exception.args, exception.prefix),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
if (!result) {
|
|
68
|
-
|
|
86
|
+
const message = await this.translate(app_exception_code_enum_1.CommonExceptionCode.UNKNOWN_ERROR, lang);
|
|
87
|
+
result = { httpStatus: 500, errorCode: app_exception_code_enum_1.CommonExceptionCode.UNKNOWN_ERROR, message };
|
|
69
88
|
}
|
|
70
89
|
httpAdapter.reply(response, common_1.JsonResponse.Error(result.errorCode, result.message), result.httpStatus);
|
|
71
90
|
}
|
|
@@ -74,10 +93,7 @@ let GlobalExceptionsFilter = GlobalExceptionsFilter_1 = class GlobalExceptionsFi
|
|
|
74
93
|
if (!this.i18nService) {
|
|
75
94
|
return key;
|
|
76
95
|
}
|
|
77
|
-
return this.i18nService.translate(key, {
|
|
78
|
-
lang,
|
|
79
|
-
args,
|
|
80
|
-
});
|
|
96
|
+
return this.i18nService.translate(key, { lang, args });
|
|
81
97
|
}
|
|
82
98
|
};
|
|
83
99
|
exports.GlobalExceptionsFilter = GlobalExceptionsFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../lib/exception/global-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA+C;AAC/C,2CAOwB;AACxB,uCAA+C;AAC/C,6CAA0C;AAE1C,uCAA4C;AAC5C,+DAA2D;
|
|
1
|
+
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../lib/exception/global-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA+C;AAC/C,2CAOwB;AACxB,uCAA+C;AAC/C,6CAA0C;AAE1C,uCAA4C;AAC5C,+DAA2D;AAC3D,uEAAgE;AAChE,mDAA+C;AAQxC,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAMjC,YACmB,eAAgC,EACrC,WAA0C,EACd,gBAAqC;QAF5D,oBAAe,GAAf,eAAe,CAAiB;QACpB,gBAAW,GAAX,WAAW,CAAc;QALvC,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;QACjD,oBAAe,GAAG,WAAW,CAAC;QAO7C,IAAI,CAAC,QAAQ,GAAG;YACd,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;YAC3B,GAAG,KAAK,CAAC,IAAI,CAAC,wBAAsB,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;YAC7D,GAAG,yBAAe;SACnB,CAAC;IACJ,CAAC;IAQD,MAAM,CAAC,eAAe,CAAC,OAAyB;QAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;QACtC,IAAI,CAAC,wBAAsB,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,wBAAsB,CAAC,cAAc,CAAC,GAAG,CAA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CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;;AAlHU,wDAAsB;AAClB,qCAAc,GAAG,IAAI,GAAG,EAA4B,AAAtC,CAAuC;iCADzD,sBAAsB;IADlC,IAAA,cAAK,GAAE;IASH,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,wCAAkB,CAAC,CAAA;qCAFL,sBAAe;QACN,yBAAW;GAR7C,sBAAsB,CAmHlC"}
|
|
@@ -12,11 +12,17 @@ class AppExceptionHandler {
|
|
|
12
12
|
return exception instanceof app_exception_1.AppException;
|
|
13
13
|
}
|
|
14
14
|
async handle(exception, context) {
|
|
15
|
+
var _a;
|
|
15
16
|
const appException = exception;
|
|
16
17
|
const errorCode = appException.code;
|
|
17
|
-
const httpStatus = appException.httpStatus
|
|
18
|
+
const httpStatus = (_a = appException.httpStatus) !== null && _a !== void 0 ? _a : this.getStatusCodeFromErrorCode(errorCode);
|
|
18
19
|
const message = await context.translate(errorCode, context.lang, appException.args, appException.prefix);
|
|
19
|
-
|
|
20
|
+
if (httpStatus >= 500) {
|
|
21
|
+
this.logger.error(`AppException: ret: ${errorCode} - ${message}`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.logger.warn(`AppException: ret: ${errorCode} - ${message}`);
|
|
25
|
+
}
|
|
20
26
|
return {
|
|
21
27
|
httpStatus,
|
|
22
28
|
errorCode,
|
|
@@ -25,16 +31,23 @@ class AppExceptionHandler {
|
|
|
25
31
|
}
|
|
26
32
|
getStatusCodeFromErrorCode(errorCode) {
|
|
27
33
|
switch (errorCode) {
|
|
34
|
+
case app_exception_code_enum_1.CommonExceptionCode.REQUEST_PARAMETER_ERROR:
|
|
35
|
+
case app_exception_code_enum_1.CommonExceptionCode.REQUEST_INVALID:
|
|
36
|
+
return 400;
|
|
28
37
|
case app_exception_code_enum_1.CommonExceptionCode.UNAUTHORIZED:
|
|
29
38
|
return 401;
|
|
30
|
-
case app_exception_code_enum_1.CommonExceptionCode.NOT_FOUND:
|
|
31
|
-
return 404;
|
|
32
39
|
case app_exception_code_enum_1.CommonExceptionCode.FORBIDDEN:
|
|
33
40
|
case app_exception_code_enum_1.CommonExceptionCode.FORBIDDEN_IP_NOT_MATCH:
|
|
34
41
|
case app_exception_code_enum_1.CommonExceptionCode.FORBIDDEN_BLACKLISTED:
|
|
42
|
+
case app_exception_code_enum_1.CommonExceptionCode.CAPTCHA_ERROR:
|
|
35
43
|
case app_exception_code_enum_1.CommonExceptionCode.TWO_FACTOR_REQUIRED:
|
|
36
44
|
case app_exception_code_enum_1.CommonExceptionCode.TWO_FACTOR_INVALID:
|
|
37
45
|
return 403;
|
|
46
|
+
case app_exception_code_enum_1.CommonExceptionCode.NOT_FOUND:
|
|
47
|
+
case app_exception_code_enum_1.CommonExceptionCode.USER_NOT_FOUND:
|
|
48
|
+
return 404;
|
|
49
|
+
case app_exception_code_enum_1.CommonExceptionCode.TOO_MANY_REQUESTS:
|
|
50
|
+
return 429;
|
|
38
51
|
default:
|
|
39
52
|
return 500;
|
|
40
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-exception.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/app-exception.handler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,oDAAgD;AAChD,wEAAiE;AAGjE,MAAa,mBAAmB;IAAhC;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"app-exception.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/app-exception.handler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,oDAAgD;A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;YAC/C,KAAK,6CAAmB,CAAC,aAAa,CAAC;YACvC,KAAK,6CAAmB,CAAC,mBAAmB,CAAC;YAC7C,KAAK,6CAAmB,CAAC,kBAAkB;gBACzC,OAAO,GAAG,CAAC;YACb,KAAK,6CAAmB,CAAC,SAAS,CAAC;YACnC,KAAK,6CAAmB,CAAC,cAAc;gBACrC,OAAO,GAAG,CAAC;YACb,KAAK,6CAAmB,CAAC,iBAAiB;gBACxC,OAAO,GAAG,CAAC;YACb;gBACE,OAAO,GAAG,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAtDD,kDAsDC"}
|
|
@@ -6,6 +6,5 @@ export { NotFoundExceptionHandler } from "./not-found.handler";
|
|
|
6
6
|
export { BadRequestExceptionHandler } from "./bad-request.handler";
|
|
7
7
|
export { MicroServiceExceptionHandler } from "./microservice.handler";
|
|
8
8
|
export { ThrottlerExceptionHandler } from "./throttler.handler";
|
|
9
|
-
export { UsernameNotFoundExceptionHandler } from "./username-not-found.handler";
|
|
10
9
|
export { UnknownExceptionHandler } from "./unknown.handler";
|
|
11
10
|
export declare const builtInHandlers: ExceptionHandler[];
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.builtInHandlers = exports.UnknownExceptionHandler = exports.
|
|
3
|
+
exports.builtInHandlers = exports.UnknownExceptionHandler = exports.ThrottlerExceptionHandler = exports.MicroServiceExceptionHandler = exports.BadRequestExceptionHandler = exports.NotFoundExceptionHandler = exports.ForbiddenExceptionHandler = exports.AppExceptionHandler = void 0;
|
|
4
4
|
const app_exception_handler_1 = require("./app-exception.handler");
|
|
5
5
|
const forbidden_handler_1 = require("./forbidden.handler");
|
|
6
6
|
const not_found_handler_1 = require("./not-found.handler");
|
|
7
7
|
const bad_request_handler_1 = require("./bad-request.handler");
|
|
8
8
|
const microservice_handler_1 = require("./microservice.handler");
|
|
9
9
|
const throttler_handler_1 = require("./throttler.handler");
|
|
10
|
-
const username_not_found_handler_1 = require("./username-not-found.handler");
|
|
11
10
|
const unknown_handler_1 = require("./unknown.handler");
|
|
12
11
|
var app_exception_handler_2 = require("./app-exception.handler");
|
|
13
12
|
Object.defineProperty(exports, "AppExceptionHandler", { enumerable: true, get: function () { return app_exception_handler_2.AppExceptionHandler; } });
|
|
@@ -21,13 +20,10 @@ var microservice_handler_2 = require("./microservice.handler");
|
|
|
21
20
|
Object.defineProperty(exports, "MicroServiceExceptionHandler", { enumerable: true, get: function () { return microservice_handler_2.MicroServiceExceptionHandler; } });
|
|
22
21
|
var throttler_handler_2 = require("./throttler.handler");
|
|
23
22
|
Object.defineProperty(exports, "ThrottlerExceptionHandler", { enumerable: true, get: function () { return throttler_handler_2.ThrottlerExceptionHandler; } });
|
|
24
|
-
var username_not_found_handler_2 = require("./username-not-found.handler");
|
|
25
|
-
Object.defineProperty(exports, "UsernameNotFoundExceptionHandler", { enumerable: true, get: function () { return username_not_found_handler_2.UsernameNotFoundExceptionHandler; } });
|
|
26
23
|
var unknown_handler_2 = require("./unknown.handler");
|
|
27
24
|
Object.defineProperty(exports, "UnknownExceptionHandler", { enumerable: true, get: function () { return unknown_handler_2.UnknownExceptionHandler; } });
|
|
28
25
|
exports.builtInHandlers = [
|
|
29
26
|
new app_exception_handler_1.AppExceptionHandler(),
|
|
30
|
-
new username_not_found_handler_1.UsernameNotFoundExceptionHandler(),
|
|
31
27
|
new forbidden_handler_1.ForbiddenExceptionHandler(),
|
|
32
28
|
new not_found_handler_1.NotFoundExceptionHandler(),
|
|
33
29
|
new bad_request_handler_1.BadRequestExceptionHandler(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/exception/handler/index.ts"],"names":[],"mappings":";;;AACA,mEAA8D;AAC9D,2DAAgE;AAChE,2DAA+D;AAC/D,+DAAmE;AACnE,iEAAsE;AACtE,2DAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/exception/handler/index.ts"],"names":[],"mappings":";;;AACA,mEAA8D;AAC9D,2DAAgE;AAChE,2DAA+D;AAC/D,+DAAmE;AACnE,iEAAsE;AACtE,2DAAgE;AAChE,uDAA4D;AAG5D,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,yDAAgE;AAAvD,8HAAA,yBAAyB,OAAA;AAClC,yDAA+D;AAAtD,6HAAA,wBAAwB,OAAA;AACjC,6DAAmE;AAA1D,iIAAA,0BAA0B,OAAA;AACnC,+DAAsE;AAA7D,oIAAA,4BAA4B,OAAA;AACrC,yDAAgE;AAAvD,8HAAA,yBAAyB,OAAA;AAClC,qDAA4D;AAAnD,0HAAA,uBAAuB,OAAA;AAOnB,QAAA,eAAe,GAAuB;IACjD,IAAI,2CAAmB,EAAE;IACzB,IAAI,6CAAyB,EAAE;IAC/B,IAAI,4CAAwB,EAAE;IAC9B,IAAI,gDAA0B,EAAE;IAChC,IAAI,mDAA4B,EAAE;IAClC,IAAI,6CAAyB,EAAE;IAC/B,IAAI,yCAAuB,EAAE;CAC9B,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { CommonExceptionCode } from "./app-exception-code.enum";
|
|
2
2
|
import { AppException, AppExceptionArgs } from "./app.exception";
|
|
3
|
-
import { CaptchaException } from "./captcha.exception";
|
|
4
3
|
import { DefaultI18nValidationExceptionFilter, defaultResponseFormatter } from "./default-i18n-validation-exception.filter";
|
|
5
4
|
import { GlobalExceptionsFilter } from "./global-exception.filter";
|
|
6
5
|
import { I18nValidationExceptionFilter, type I18nValidationExceptionFilterOptions } from "./i18n-validation-exception.filter";
|
|
7
6
|
import { HttpMicroServiceException } from "./micro-service.exception";
|
|
8
|
-
import { TwoFactorInvalidException, TwoFactorRequiredException } from "./two-factor.exception";
|
|
9
7
|
import { UsernameNotFoundException } from "./user-not-found.exception";
|
|
10
|
-
import { AuthException, ForbiddenAppException,
|
|
8
|
+
import { AuthException, CaptchaException, ForbiddenAppException, InternalAppException, NotFoundAppException, ThrottleAppException, TwoFactorInvalidException, TwoFactorRequiredException, ValidationAppException } from "./exceptions";
|
|
11
9
|
import { ExceptionModule } from "./exception.module";
|
|
12
10
|
import { EXCEPTION_HANDLERS } from "./exception.constants";
|
|
13
|
-
export { AppException, AppExceptionArgs, GlobalExceptionsFilter, UsernameNotFoundException, CommonExceptionCode, HttpMicroServiceException, defaultResponseFormatter, DefaultI18nValidationExceptionFilter, type I18nValidationExceptionFilterOptions, I18nValidationExceptionFilter, CaptchaException, TwoFactorRequiredException, TwoFactorInvalidException, AuthException, ForbiddenAppException, NotFoundAppException, ValidationAppException, ThrottleAppException, InternalAppException, ExceptionModule, EXCEPTION_HANDLERS };
|
|
11
|
+
export { AppException, AppExceptionArgs, GlobalExceptionsFilter, UsernameNotFoundException, CommonExceptionCode, HttpMicroServiceException, defaultResponseFormatter, DefaultI18nValidationExceptionFilter, type I18nValidationExceptionFilterOptions, I18nValidationExceptionFilter, CaptchaException, TwoFactorRequiredException, TwoFactorInvalidException, AuthException, ForbiddenAppException, NotFoundAppException, ValidationAppException, ThrottleAppException, InternalAppException, ExceptionModule, EXCEPTION_HANDLERS, };
|
|
14
12
|
export type { ExceptionHandler, ExceptionContext, ExceptionResult } from "./handler";
|
package/dist/exception/index.js
CHANGED
|
@@ -5,8 +5,6 @@ const app_exception_code_enum_1 = require("./app-exception-code.enum");
|
|
|
5
5
|
Object.defineProperty(exports, "CommonExceptionCode", { enumerable: true, get: function () { return app_exception_code_enum_1.CommonExceptionCode; } });
|
|
6
6
|
const app_exception_1 = require("./app.exception");
|
|
7
7
|
Object.defineProperty(exports, "AppException", { enumerable: true, get: function () { return app_exception_1.AppException; } });
|
|
8
|
-
const captcha_exception_1 = require("./captcha.exception");
|
|
9
|
-
Object.defineProperty(exports, "CaptchaException", { enumerable: true, get: function () { return captcha_exception_1.CaptchaException; } });
|
|
10
8
|
const default_i18n_validation_exception_filter_1 = require("./default-i18n-validation-exception.filter");
|
|
11
9
|
Object.defineProperty(exports, "DefaultI18nValidationExceptionFilter", { enumerable: true, get: function () { return default_i18n_validation_exception_filter_1.DefaultI18nValidationExceptionFilter; } });
|
|
12
10
|
Object.defineProperty(exports, "defaultResponseFormatter", { enumerable: true, get: function () { return default_i18n_validation_exception_filter_1.defaultResponseFormatter; } });
|
|
@@ -16,18 +14,18 @@ const i18n_validation_exception_filter_1 = require("./i18n-validation-exception.
|
|
|
16
14
|
Object.defineProperty(exports, "I18nValidationExceptionFilter", { enumerable: true, get: function () { return i18n_validation_exception_filter_1.I18nValidationExceptionFilter; } });
|
|
17
15
|
const micro_service_exception_1 = require("./micro-service.exception");
|
|
18
16
|
Object.defineProperty(exports, "HttpMicroServiceException", { enumerable: true, get: function () { return micro_service_exception_1.HttpMicroServiceException; } });
|
|
19
|
-
const two_factor_exception_1 = require("./two-factor.exception");
|
|
20
|
-
Object.defineProperty(exports, "TwoFactorInvalidException", { enumerable: true, get: function () { return two_factor_exception_1.TwoFactorInvalidException; } });
|
|
21
|
-
Object.defineProperty(exports, "TwoFactorRequiredException", { enumerable: true, get: function () { return two_factor_exception_1.TwoFactorRequiredException; } });
|
|
22
17
|
const user_not_found_exception_1 = require("./user-not-found.exception");
|
|
23
18
|
Object.defineProperty(exports, "UsernameNotFoundException", { enumerable: true, get: function () { return user_not_found_exception_1.UsernameNotFoundException; } });
|
|
24
19
|
const exceptions_1 = require("./exceptions");
|
|
25
20
|
Object.defineProperty(exports, "AuthException", { enumerable: true, get: function () { return exceptions_1.AuthException; } });
|
|
21
|
+
Object.defineProperty(exports, "CaptchaException", { enumerable: true, get: function () { return exceptions_1.CaptchaException; } });
|
|
26
22
|
Object.defineProperty(exports, "ForbiddenAppException", { enumerable: true, get: function () { return exceptions_1.ForbiddenAppException; } });
|
|
23
|
+
Object.defineProperty(exports, "InternalAppException", { enumerable: true, get: function () { return exceptions_1.InternalAppException; } });
|
|
27
24
|
Object.defineProperty(exports, "NotFoundAppException", { enumerable: true, get: function () { return exceptions_1.NotFoundAppException; } });
|
|
28
|
-
Object.defineProperty(exports, "ValidationAppException", { enumerable: true, get: function () { return exceptions_1.ValidationAppException; } });
|
|
29
25
|
Object.defineProperty(exports, "ThrottleAppException", { enumerable: true, get: function () { return exceptions_1.ThrottleAppException; } });
|
|
30
|
-
Object.defineProperty(exports, "
|
|
26
|
+
Object.defineProperty(exports, "TwoFactorInvalidException", { enumerable: true, get: function () { return exceptions_1.TwoFactorInvalidException; } });
|
|
27
|
+
Object.defineProperty(exports, "TwoFactorRequiredException", { enumerable: true, get: function () { return exceptions_1.TwoFactorRequiredException; } });
|
|
28
|
+
Object.defineProperty(exports, "ValidationAppException", { enumerable: true, get: function () { return exceptions_1.ValidationAppException; } });
|
|
31
29
|
const exception_module_1 = require("./exception.module");
|
|
32
30
|
Object.defineProperty(exports, "ExceptionModule", { enumerable: true, get: function () { return exception_module_1.ExceptionModule; } });
|
|
33
31
|
const exception_constants_1 = require("./exception.constants");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/exception/index.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/exception/index.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AA0B9D,oGA1BO,6CAAmB,OA0BP;AAzBrB,mDAAiE;AAqB/D,6FArBO,4BAAY,OAqBP;AApBd,yGAA4H;AA2B1H,qHA3BO,+EAAoC,OA2BP;AADpC,yGA1B6C,mEAAwB,OA0B7C;AAzB1B,uEAAmE;AAqBjE,uGArBO,gDAAsB,OAqBP;AApBxB,yFAA8H;AA2B5H,8GA3BO,gEAA6B,OA2BP;AA1B/B,uEAAsE;AAsBpE,0GAtBO,mDAAyB,OAsBP;AArB3B,yEAAuE;AAmBrE,0GAnBO,oDAAyB,OAmBP;AAlB3B,6CAUsB;AAkBpB,8FA3BA,0BAAa,OA2BA;AAHb,iGAvBA,6BAAgB,OAuBA;AAIhB,sGA1BA,kCAAqB,OA0BA;AAIrB,qGA7BA,iCAAoB,OA6BA;AAHpB,qGAzBA,iCAAoB,OAyBA;AAEpB,qGA1BA,iCAAoB,OA0BA;AALpB,0GApBA,sCAAyB,OAoBA;AADzB,2GAlBA,uCAA0B,OAkBA;AAK1B,uGAtBA,mCAAsB,OAsBA;AApBxB,yDAAqD;AAuBnD,gGAvBO,kCAAe,OAuBP;AAtBjB,+DAA2D;AAuBzD,mGAvBO,wCAAkB,OAuBP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class UsernameNotFoundException extends
|
|
3
|
-
constructor(
|
|
1
|
+
import { AppException } from "./app.exception";
|
|
2
|
+
export declare class UsernameNotFoundException extends AppException {
|
|
3
|
+
constructor(_message?: string);
|
|
4
4
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UsernameNotFoundException = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const app_exception_code_enum_1 = require("./app-exception-code.enum");
|
|
5
|
+
const app_exception_1 = require("./app.exception");
|
|
6
|
+
class UsernameNotFoundException extends app_exception_1.AppException {
|
|
7
|
+
constructor(_message) {
|
|
8
|
+
super(app_exception_code_enum_1.CommonExceptionCode.USER_NOT_FOUND, undefined, undefined, 404);
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
exports.UsernameNotFoundException = UsernameNotFoundException;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-not-found.exception.js","sourceRoot":"","sources":["../../lib/exception/user-not-found.exception.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"user-not-found.exception.js","sourceRoot":"","sources":["../../lib/exception/user-not-found.exception.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,mDAA+C;AAE/C,MAAa,yBAA0B,SAAQ,4BAAY;IACzD,YAAY,QAAiB;QAC3B,KAAK,CAAC,6CAAmB,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IACvE,CAAC;CACF;AAJD,8DAIC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"captcha.exception.js","sourceRoot":"","sources":["../../lib/exception/captcha.exception.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,mDAA+C;AAE/C,MAAa,gBAAiB,SAAQ,4BAAY;IAChD,YAAY,IAAU,EAAE,MAAe;QACrC,KAAK,CAAC,6CAAmB,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;CACF;AAJD,4CAIC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ExceptionContext, ExceptionHandler, ExceptionResult } from "./exception-handler.interface";
|
|
2
|
-
export declare class UsernameNotFoundExceptionHandler implements ExceptionHandler {
|
|
3
|
-
private readonly logger;
|
|
4
|
-
canHandle(exception: unknown): boolean;
|
|
5
|
-
handle(exception: unknown, context: ExceptionContext): Promise<ExceptionResult>;
|
|
6
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UsernameNotFoundExceptionHandler = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const app_exception_code_enum_1 = require("../app-exception-code.enum");
|
|
6
|
-
const user_not_found_exception_1 = require("../user-not-found.exception");
|
|
7
|
-
class UsernameNotFoundExceptionHandler {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.logger = new common_1.Logger(UsernameNotFoundExceptionHandler.name);
|
|
10
|
-
}
|
|
11
|
-
canHandle(exception) {
|
|
12
|
-
return exception instanceof user_not_found_exception_1.UsernameNotFoundException;
|
|
13
|
-
}
|
|
14
|
-
async handle(exception, context) {
|
|
15
|
-
const usernameNotFoundException = exception;
|
|
16
|
-
const httpStatus = 404;
|
|
17
|
-
const errorCode = app_exception_code_enum_1.CommonExceptionCode.USER_NOT_FOUND;
|
|
18
|
-
const message = await context.translate(errorCode, context.lang);
|
|
19
|
-
this.logger.warn(usernameNotFoundException.message, user_not_found_exception_1.UsernameNotFoundException.name);
|
|
20
|
-
return {
|
|
21
|
-
httpStatus,
|
|
22
|
-
errorCode,
|
|
23
|
-
message,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.UsernameNotFoundExceptionHandler = UsernameNotFoundExceptionHandler;
|
|
28
|
-
//# sourceMappingURL=username-not-found.handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"username-not-found.handler.js","sourceRoot":"","sources":["../../../lib/exception/handler/username-not-found.handler.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,wEAAiE;AACjE,0EAAwE;AAGxE,MAAa,gCAAgC;IAA7C;QACmB,WAAM,GAAG,IAAI,eAAM,CAAC,gCAAgC,CAAC,IAAI,CAAC,CAAC;IAoB9E,CAAC;IAlBC,SAAS,CAAC,SAAkB;QAC1B,OAAO,SAAS,YAAY,oDAAyB,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAkB,EAAE,OAAyB;QACxD,MAAM,yBAAyB,GAAG,SAAsC,CAAC;QACzE,MAAM,UAAU,GAAG,GAAG,CAAC;QACvB,MAAM,SAAS,GAAG,6CAAmB,CAAC,cAAc,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAEjE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,oDAAyB,CAAC,IAAI,CAAC,CAAC;QAEpF,OAAO;YACL,UAAU;YACV,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AArBD,4EAqBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"two-factor.exception.js","sourceRoot":"","sources":["../../lib/exception/two-factor.exception.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,mDAA+C;AAE/C,MAAa,0BAA2B,SAAQ,4BAAY;IAC1D;QACE,KAAK,CAAC,6CAAmB,CAAC,mBAAmB,CAAC,CAAC;IACjD,CAAC;CACF;AAJD,gEAIC;AAED,MAAa,yBAA0B,SAAQ,4BAAY;IACzD;QACE,KAAK,CAAC,6CAAmB,CAAC,kBAAkB,CAAC,CAAC;IAChD,CAAC;CACF;AAJD,8DAIC"}
|