@munlib/common 1.0.117 → 1.0.119
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.
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.RequestValidationError = void 0;
|
|
19
19
|
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var erroresStatus_1 = require("./erroresStatus");
|
|
20
21
|
var RequestValidationError = /** @class */ (function (_super) {
|
|
21
22
|
__extends(RequestValidationError, _super);
|
|
22
23
|
function RequestValidationError(errors) {
|
|
@@ -30,7 +31,7 @@ var RequestValidationError = /** @class */ (function (_super) {
|
|
|
30
31
|
RequestValidationError.prototype.serializeErrors = function () {
|
|
31
32
|
var _this = this;
|
|
32
33
|
return this.errors.map(function (err) {
|
|
33
|
-
return { status: _this.statusCode, msg: err.msg, field: err.param };
|
|
34
|
+
return { status: erroresStatus_1.ErrorController.getGeneralStatus(_this.statusCode.toString()), msg: err.msg, field: err.param };
|
|
34
35
|
});
|
|
35
36
|
};
|
|
36
37
|
return RequestValidationError;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorHandler = void 0;
|
|
4
4
|
var custom_error_1 = require("../errors/custom-error");
|
|
5
|
+
var erroresStatus_1 = require("../errors/erroresStatus");
|
|
5
6
|
var errorHandler = function (err, req, res, next) {
|
|
6
7
|
// Manejo de errores personalizados
|
|
7
8
|
if (err instanceof custom_error_1.CustomError) {
|
|
@@ -10,10 +11,8 @@ var errorHandler = function (err, req, res, next) {
|
|
|
10
11
|
// Manejo de errores genéricos
|
|
11
12
|
var statusCode = 400; // Código de estado por defecto para errores genéricos
|
|
12
13
|
res.status(statusCode).send({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
status: statusCode // Agregar el código de estado al objeto de errores
|
|
16
|
-
}],
|
|
14
|
+
status: erroresStatus_1.ErrorController.getGeneralStatus(statusCode.toString()),
|
|
15
|
+
msg: err.message, // Agregar el código de estado al objeto de errores
|
|
17
16
|
});
|
|
18
17
|
};
|
|
19
18
|
exports.errorHandler = errorHandler;
|