@munlib/common 1.0.156 → 1.0.157
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.
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export declare abstract class CustomError extends Error {
|
|
2
|
+
typeError?: string | undefined;
|
|
3
|
+
userMsg?: string | undefined;
|
|
2
4
|
abstract statusCode: number;
|
|
3
|
-
constructor(msg: string);
|
|
5
|
+
constructor(msg: string, typeError?: string | undefined, userMsg?: string | undefined);
|
|
4
6
|
abstract serializeErrors(): {
|
|
5
7
|
msg: string;
|
|
6
|
-
field?: string;
|
|
7
8
|
status: string;
|
|
8
9
|
code: string;
|
|
10
|
+
typeError?: string;
|
|
11
|
+
userMsg?: string;
|
|
9
12
|
};
|
|
10
13
|
}
|
|
@@ -18,8 +18,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.CustomError = void 0;
|
|
19
19
|
var CustomError = /** @class */ (function (_super) {
|
|
20
20
|
__extends(CustomError, _super);
|
|
21
|
-
function CustomError(msg) {
|
|
21
|
+
function CustomError(msg, typeError, userMsg) {
|
|
22
22
|
var _this = _super.call(this, msg) || this;
|
|
23
|
+
_this.typeError = typeError;
|
|
24
|
+
_this.userMsg = userMsg;
|
|
23
25
|
Object.setPrototypeOf(_this, CustomError.prototype);
|
|
24
26
|
return _this;
|
|
25
27
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CustomError } from './custom-error';
|
|
2
2
|
export declare class NotAuthorizedError extends CustomError {
|
|
3
3
|
statusCode: number;
|
|
4
|
-
constructor();
|
|
4
|
+
constructor(typeError?: string, userMsg?: string);
|
|
5
5
|
serializeErrors(): {
|
|
6
6
|
status: string;
|
|
7
7
|
msg: string;
|
|
8
8
|
code: string;
|
|
9
|
+
typeError: string | undefined;
|
|
10
|
+
userMsg: string | undefined;
|
|
9
11
|
};
|
|
10
12
|
}
|
|
@@ -20,14 +20,20 @@ var custom_error_1 = require("./custom-error");
|
|
|
20
20
|
var erroresStatus_1 = require("./erroresStatus");
|
|
21
21
|
var NotAuthorizedError = /** @class */ (function (_super) {
|
|
22
22
|
__extends(NotAuthorizedError, _super);
|
|
23
|
-
function NotAuthorizedError() {
|
|
24
|
-
var _this = _super.call(this, 'Not Authorized') || this;
|
|
23
|
+
function NotAuthorizedError(typeError, userMsg) {
|
|
24
|
+
var _this = _super.call(this, 'Not Authorized', typeError, userMsg) || this;
|
|
25
25
|
_this.statusCode = 401;
|
|
26
26
|
Object.setPrototypeOf(_this, NotAuthorizedError.prototype);
|
|
27
27
|
return _this;
|
|
28
28
|
}
|
|
29
29
|
NotAuthorizedError.prototype.serializeErrors = function () {
|
|
30
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()),
|
|
32
|
+
msg: erroresStatus_1.ErrorController.getErrorMessage(this.statusCode.toString()),
|
|
33
|
+
code: this.statusCode.toString(),
|
|
34
|
+
typeError: this.typeError, // Añadir typeError
|
|
35
|
+
userMsg: this.userMsg, // Añadir userMsg
|
|
36
|
+
};
|
|
31
37
|
};
|
|
32
38
|
return NotAuthorizedError;
|
|
33
39
|
}(custom_error_1.CustomError));
|
|
@@ -3,20 +3,19 @@ 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
|
-
//import {apmInstance} from './apm';
|
|
7
6
|
var errorHandler = function (err, req, res, next) {
|
|
8
|
-
//
|
|
9
|
-
//apmInstance.captureError(err);
|
|
10
|
-
// Manejo de errores personalizados
|
|
7
|
+
var statusCode = 500; // Código de estado por defecto para errores genéricos
|
|
11
8
|
if (err instanceof custom_error_1.CustomError) {
|
|
9
|
+
console.log("ENTRA A CUSTOM ERROR******");
|
|
12
10
|
return res.status(err.statusCode).send(err.serializeErrors());
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
var statusCode = 400; // Código de estado por defecto para errores genéricos
|
|
12
|
+
console.log("NO===> ENTRA A CUSTOM ERROR");
|
|
16
13
|
res.status(statusCode).send({
|
|
17
14
|
status: erroresStatus_1.ErrorController.getGeneralStatus(statusCode.toString()),
|
|
18
15
|
msg: err.message, // Agregar el código de estado al objeto de errores
|
|
19
|
-
code: statusCode
|
|
16
|
+
code: statusCode,
|
|
17
|
+
typeError: "Middleware",
|
|
18
|
+
userMsg: "Hemos encontrado un problema al procesar su solicitud. Inténtelo nuevamente más tarde o contacte al soporte si el problema persiste."
|
|
20
19
|
});
|
|
21
20
|
};
|
|
22
21
|
exports.errorHandler = errorHandler;
|