@munlib/common 1.0.157 → 1.0.160
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.
|
@@ -75,7 +75,7 @@ exports.errorCodes = {
|
|
|
75
75
|
"M010": "No se puede procesar una orden que ya fue pagada",
|
|
76
76
|
"M011": "Error al consultar Rubros",
|
|
77
77
|
"M012": "La Consulta se realizo con exito",
|
|
78
|
-
"M013": "
|
|
78
|
+
"M013": "API Key de Middleware Invalida",
|
|
79
79
|
"M014": "Error al generar comprobante de pago",
|
|
80
80
|
"M015": "Error al obtener Total Pagado",
|
|
81
81
|
"M016": "Error al obtener Comprobante de una orden no pagada/reversada",
|
|
@@ -134,6 +134,11 @@ exports.errorCodes = {
|
|
|
134
134
|
"ERR_BAD_RESPONSE": "El servidor respondio, pero la respuesta no fue valida.",
|
|
135
135
|
"ERR_TIMEOUT": "La solicitud tomo demasiado tiempo para completarse",
|
|
136
136
|
"ERR_CANCELED": "La solicitud fue cancelada antes de completarse.",
|
|
137
|
+
//Errores Especificos PARA EL USURIO
|
|
138
|
+
"MIDDLEWARE": "Error interno de Sistema. Inténtelo nuevamente más tarde.",
|
|
139
|
+
"USUARIO": "",
|
|
140
|
+
"TECNICO": "Hemos encontrado un problema al procesar su solicitud. Inténtelo nuevamente más tarde.",
|
|
141
|
+
"SUCCESS": "",
|
|
137
142
|
};
|
|
138
143
|
exports.statusCodeMapping = {
|
|
139
144
|
"E000": "success",
|
|
@@ -269,7 +274,11 @@ exports.statusCodeMapping = {
|
|
|
269
274
|
"ERR_NETWORK": "error",
|
|
270
275
|
"ERR_BAD_RESPONSE": "error",
|
|
271
276
|
"ERR_TIMEOUT": "error",
|
|
272
|
-
"ERR_CANCELED": "error"
|
|
277
|
+
"ERR_CANCELED": "error",
|
|
278
|
+
"MIDDLEWARE": "error",
|
|
279
|
+
"USUARIO": "error",
|
|
280
|
+
"TECNICO": "error",
|
|
281
|
+
"SUCCESS": "success",
|
|
273
282
|
};
|
|
274
283
|
var ErrorController = /** @class */ (function () {
|
|
275
284
|
function ErrorController() {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CustomError } from './custom-error';
|
|
2
|
+
export declare class GenericError extends CustomError {
|
|
3
|
+
msg: string;
|
|
4
|
+
code: string;
|
|
5
|
+
typeError: string;
|
|
6
|
+
userMsg: string;
|
|
7
|
+
statusCode: number;
|
|
8
|
+
constructor(msg: string, // Mensaje principal del error
|
|
9
|
+
code?: string, // Código de estado (por defecto 500)
|
|
10
|
+
typeError?: string, // Tipo de error opcional
|
|
11
|
+
userMsg?: string);
|
|
12
|
+
serializeErrors(): {
|
|
13
|
+
msg: string;
|
|
14
|
+
status: string;
|
|
15
|
+
code: string;
|
|
16
|
+
typeError: string;
|
|
17
|
+
userMsg: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.GenericError = void 0;
|
|
19
|
+
var custom_error_1 = require("./custom-error"); // Asegúrate de importar tu clase base
|
|
20
|
+
var erroresStatus_1 = require("./erroresStatus");
|
|
21
|
+
var GenericError = /** @class */ (function (_super) {
|
|
22
|
+
__extends(GenericError, _super);
|
|
23
|
+
function GenericError(msg, // Mensaje principal del error
|
|
24
|
+
code, // Código de estado (por defecto 500)
|
|
25
|
+
typeError, // Tipo de error opcional
|
|
26
|
+
userMsg // Mensaje amigable para el usuario
|
|
27
|
+
) {
|
|
28
|
+
if (code === void 0) { code = "500"; }
|
|
29
|
+
if (typeError === void 0) { typeError = "MIDDLEWARE"; }
|
|
30
|
+
if (userMsg === void 0) { userMsg = "Hemos encontrado un problema. Inténtelo nuevamente más tarde."; }
|
|
31
|
+
var _this = _super.call(this, msg, typeError, userMsg) || this;
|
|
32
|
+
_this.msg = msg;
|
|
33
|
+
_this.code = code;
|
|
34
|
+
_this.typeError = typeError;
|
|
35
|
+
_this.userMsg = userMsg;
|
|
36
|
+
_this.statusCode = 500; // Convertir el código a número para HTTP
|
|
37
|
+
_this.msg = erroresStatus_1.ErrorController.getErrorMessage(code) || _this.message;
|
|
38
|
+
Object.setPrototypeOf(_this, GenericError.prototype);
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
GenericError.prototype.serializeErrors = function () {
|
|
42
|
+
return {
|
|
43
|
+
msg: this.message,
|
|
44
|
+
status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()),
|
|
45
|
+
code: this.code.toString(),
|
|
46
|
+
typeError: this.typeError,
|
|
47
|
+
userMsg: this.userMsg
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
return GenericError;
|
|
51
|
+
}(custom_error_1.CustomError));
|
|
52
|
+
exports.GenericError = GenericError;
|
package/build/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './errors/database-connection-error';
|
|
|
4
4
|
export * from './errors/not-authorized-error';
|
|
5
5
|
export * from './errors/not-found-error';
|
|
6
6
|
export * from './errors/request-validation-error';
|
|
7
|
+
export * from './errors/genericError';
|
|
7
8
|
export * from './middlewares/error-handler';
|
|
8
9
|
export * from './middlewares/require-auth';
|
|
9
10
|
export * from './middlewares/validate-request';
|
package/build/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./errors/database-connection-error"), exports);
|
|
|
21
21
|
__exportStar(require("./errors/not-authorized-error"), exports);
|
|
22
22
|
__exportStar(require("./errors/not-found-error"), exports);
|
|
23
23
|
__exportStar(require("./errors/request-validation-error"), exports);
|
|
24
|
+
__exportStar(require("./errors/genericError"), exports);
|
|
24
25
|
//export * from './middlewares/current-user';
|
|
25
26
|
__exportStar(require("./middlewares/error-handler"), exports);
|
|
26
27
|
__exportStar(require("./middlewares/require-auth"), exports);
|
|
@@ -15,7 +15,7 @@ var errorHandler = function (err, req, res, next) {
|
|
|
15
15
|
msg: err.message, // Agregar el código de estado al objeto de errores
|
|
16
16
|
code: statusCode,
|
|
17
17
|
typeError: "Middleware",
|
|
18
|
-
userMsg: "
|
|
18
|
+
userMsg: ""
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
exports.errorHandler = errorHandler;
|