@munlib/common 1.0.167 → 1.0.170
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.
|
@@ -18,3 +18,15 @@ export declare class GenericError extends CustomError {
|
|
|
18
18
|
userMsg: string;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
export declare class ValidationError extends CustomError {
|
|
22
|
+
userMsg: string;
|
|
23
|
+
statusCode: number;
|
|
24
|
+
constructor(msg: string, userMsg: string);
|
|
25
|
+
serializeErrors(): {
|
|
26
|
+
msg: string;
|
|
27
|
+
status: string;
|
|
28
|
+
code: string;
|
|
29
|
+
typeError: string | undefined;
|
|
30
|
+
userMsg: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -15,7 +15,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.GenericError = void 0;
|
|
18
|
+
exports.ValidationError = exports.GenericError = void 0;
|
|
19
|
+
var instituciones_pagos_1 = require("../events/types/instituciones-pagos");
|
|
19
20
|
var custom_error_1 = require("./custom-error"); // Asegúrate de importar tu clase base
|
|
20
21
|
var erroresStatus_1 = require("./erroresStatus");
|
|
21
22
|
var GenericError = /** @class */ (function (_super) {
|
|
@@ -26,8 +27,8 @@ var GenericError = /** @class */ (function (_super) {
|
|
|
26
27
|
userMsg // Mensaje amigable para el usuario
|
|
27
28
|
) {
|
|
28
29
|
if (code === void 0) { code = "500"; }
|
|
29
|
-
if (typeError === void 0) { typeError =
|
|
30
|
-
if (userMsg === void 0) { userMsg =
|
|
30
|
+
if (typeError === void 0) { typeError = instituciones_pagos_1.ErrorCategories.MIDDLEWARE; }
|
|
31
|
+
if (userMsg === void 0) { userMsg = erroresStatus_1.ErrorController.getErrorMessage(instituciones_pagos_1.ErrorCategories.MIDDLEWARE); }
|
|
31
32
|
var _this = _super.call(this, msg, typeError, userMsg) || this;
|
|
32
33
|
_this.msg = msg;
|
|
33
34
|
_this.httpStatus = httpStatus;
|
|
@@ -36,6 +37,8 @@ var GenericError = /** @class */ (function (_super) {
|
|
|
36
37
|
_this.userMsg = userMsg;
|
|
37
38
|
_this.statusCode = _this.httpStatus;
|
|
38
39
|
_this.msg = erroresStatus_1.ErrorController.getErrorMessage(code) || _this.message;
|
|
40
|
+
_this.typeError = _this.typeError;
|
|
41
|
+
_this.userMsg = _this.userMsg;
|
|
39
42
|
Object.setPrototypeOf(_this, GenericError.prototype);
|
|
40
43
|
return _this;
|
|
41
44
|
}
|
|
@@ -51,3 +54,24 @@ var GenericError = /** @class */ (function (_super) {
|
|
|
51
54
|
return GenericError;
|
|
52
55
|
}(custom_error_1.CustomError));
|
|
53
56
|
exports.GenericError = GenericError;
|
|
57
|
+
var ValidationError = /** @class */ (function (_super) {
|
|
58
|
+
__extends(ValidationError, _super);
|
|
59
|
+
function ValidationError(msg, userMsg) {
|
|
60
|
+
var _this = _super.call(this, msg, "VALIDATION_ERROR", userMsg) || this;
|
|
61
|
+
_this.userMsg = userMsg;
|
|
62
|
+
_this.statusCode = 400;
|
|
63
|
+
Object.setPrototypeOf(_this, ValidationError.prototype);
|
|
64
|
+
return _this;
|
|
65
|
+
}
|
|
66
|
+
ValidationError.prototype.serializeErrors = function () {
|
|
67
|
+
return {
|
|
68
|
+
msg: this.message,
|
|
69
|
+
status: "validation_failed",
|
|
70
|
+
code: "VALIDATION_ERROR",
|
|
71
|
+
typeError: this.typeError,
|
|
72
|
+
userMsg: this.userMsg,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
return ValidationError;
|
|
76
|
+
}(custom_error_1.CustomError));
|
|
77
|
+
exports.ValidationError = ValidationError;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.errorHandler = void 0;
|
|
4
4
|
var custom_error_1 = require("../errors/custom-error");
|
|
5
5
|
var erroresStatus_1 = require("../errors/erroresStatus");
|
|
6
|
+
var instituciones_pagos_1 = require("../events/types/instituciones-pagos");
|
|
6
7
|
var errorHandler = function (err, req, res, next) {
|
|
7
8
|
var statusCode = 500; // Código de estado por defecto para errores genéricos
|
|
8
9
|
if (err instanceof custom_error_1.CustomError) {
|
|
@@ -14,7 +15,7 @@ var errorHandler = function (err, req, res, next) {
|
|
|
14
15
|
status: erroresStatus_1.ErrorController.getGeneralStatus(statusCode.toString()) || "error",
|
|
15
16
|
msg: err.message, // Agregar el código de estado al objeto de errores
|
|
16
17
|
code: statusCode,
|
|
17
|
-
typeError:
|
|
18
|
+
typeError: instituciones_pagos_1.ErrorCategories.MIDDLEWARE,
|
|
18
19
|
userMsg: erroresStatus_1.ErrorController.getErrorMessage("MIDDLEWARE")
|
|
19
20
|
});
|
|
20
21
|
};
|