@munlib/common 1.0.113 → 1.0.116

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,9 +1,10 @@
1
1
  import { CustomError } from './custom-error';
2
2
  export declare class BadRequestError extends CustomError {
3
- message: string;
3
+ msg: string;
4
4
  statusCode: number;
5
- constructor(message: string, statusCode?: number);
5
+ constructor(msg: string, statusCode?: number);
6
6
  serializeErrors(): {
7
- message: string;
7
+ msg: string;
8
+ status: number;
8
9
  }[];
9
10
  }
@@ -19,16 +19,16 @@ exports.BadRequestError = void 0;
19
19
  var custom_error_1 = require("./custom-error");
20
20
  var BadRequestError = /** @class */ (function (_super) {
21
21
  __extends(BadRequestError, _super);
22
- function BadRequestError(message, statusCode) {
23
- var _this = _super.call(this, message) || this;
24
- _this.message = message;
22
+ function BadRequestError(msg, statusCode) {
23
+ var _this = _super.call(this, msg) || this;
24
+ _this.msg = msg;
25
25
  _this.statusCode = 400;
26
26
  _this.statusCode = statusCode ? _this.statusCode : 400;
27
27
  Object.setPrototypeOf(_this, BadRequestError.prototype);
28
28
  return _this;
29
29
  }
30
30
  BadRequestError.prototype.serializeErrors = function () {
31
- return [{ message: this.message }];
31
+ return [{ msg: this.message, status: this.statusCode }];
32
32
  };
33
33
  return BadRequestError;
34
34
  }(custom_error_1.CustomError));
@@ -1,8 +1,8 @@
1
1
  export declare abstract class CustomError extends Error {
2
2
  abstract statusCode: number;
3
- constructor(message: string);
3
+ constructor(msg: string);
4
4
  abstract serializeErrors(): {
5
- message: string;
5
+ msg: string;
6
6
  field?: string;
7
7
  }[];
8
8
  }
@@ -18,8 +18,8 @@ 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(message) {
22
- var _this = _super.call(this, message) || this;
21
+ function CustomError(msg) {
22
+ var _this = _super.call(this, msg) || this;
23
23
  Object.setPrototypeOf(_this, CustomError.prototype);
24
24
  return _this;
25
25
  }
@@ -4,6 +4,6 @@ export declare class DatabaseConnectionError extends CustomError {
4
4
  reason: string;
5
5
  constructor();
6
6
  serializeErrors(): {
7
- message: string;
7
+ msg: string;
8
8
  }[];
9
9
  }
@@ -27,7 +27,7 @@ var DatabaseConnectionError = /** @class */ (function (_super) {
27
27
  return _this;
28
28
  }
29
29
  DatabaseConnectionError.prototype.serializeErrors = function () {
30
- return [{ message: this.reason }];
30
+ return [{ msg: this.reason }];
31
31
  };
32
32
  return DatabaseConnectionError;
33
33
  }(custom_error_1.CustomError));
@@ -100,7 +100,16 @@ exports.errorCodes = {
100
100
  //consultas
101
101
  "OK": "La Consulta se realizó con éxito",
102
102
  "ERROR": "Se produjo un error al realizar la consulta",
103
- "TINS": "Tipo de Instalación no coincide con identificador de la deuda"
103
+ "TINS": "Tipo de Instalación no coincide con identificador de la deuda",
104
+ //Errores genrales
105
+ 'ECONNABORTED': 'La solicitud ha superado el tiempo de espera. Por favor, inténtelo de nuevo más tarde.',
106
+ 'ECONNREFUSED': 'No se pudo conectar al servidor. Por favor, verifique su conexión y vuelva a intentarlo.',
107
+ 'ENOTFOUND': 'No se pudo encontrar el servidor. Por favor, verifique la URL e inténtelo de nuevo.',
108
+ 'EHOSTUNREACH': 'El servidor está inalcanzable. Verifique su red e intente nuevamente.',
109
+ '500': 'Hubo un error en el servidor. Inténtelo más tarde.',
110
+ '404': 'No se encontró el recurso solicitado.',
111
+ '401': 'No tiene autorización para acceder a este recurso.',
112
+ '400': 'La solicitud está mal formada o contiene datos inválidos.'
104
113
  };
105
114
  exports.statusCodeMapping = {
106
115
  "E000": "success",
@@ -203,7 +212,16 @@ exports.statusCodeMapping = {
203
212
  //consultas
204
213
  "OK": "success",
205
214
  "ERROR": "error",
206
- "TINS": "error"
215
+ "TINS": "error",
216
+ //errores generales
217
+ 'ECONNABORTED': 'error',
218
+ 'ECONNREFUSED': 'error',
219
+ 'ENOTFOUND': 'error',
220
+ 'EHOSTUNREACH': 'error',
221
+ '500': 'error',
222
+ '404': 'error',
223
+ '401': 'error',
224
+ '400': 'error'
207
225
  };
208
226
  var ErrorController = /** @class */ (function () {
209
227
  function ErrorController() {
@@ -3,6 +3,6 @@ export declare class NotAuthorizedError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
5
5
  serializeErrors(): {
6
- message: string;
6
+ msg: string;
7
7
  }[];
8
8
  }
@@ -26,7 +26,7 @@ var NotAuthorizedError = /** @class */ (function (_super) {
26
26
  return _this;
27
27
  }
28
28
  NotAuthorizedError.prototype.serializeErrors = function () {
29
- return [{ message: 'Token Not authorized' }];
29
+ return [{ msg: 'Token Not authorized' }];
30
30
  };
31
31
  return NotAuthorizedError;
32
32
  }(custom_error_1.CustomError));
@@ -3,6 +3,6 @@ export declare class NotFoundError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
5
5
  serializeErrors(): {
6
- message: string;
6
+ msg: string;
7
7
  }[];
8
8
  }
@@ -26,7 +26,7 @@ var NotFoundError = /** @class */ (function (_super) {
26
26
  return _this;
27
27
  }
28
28
  NotFoundError.prototype.serializeErrors = function () {
29
- return [{ message: 'Not Found' }];
29
+ return [{ msg: 'Not Found' }];
30
30
  };
31
31
  return NotFoundError;
32
32
  }(custom_error_1.CustomError));
@@ -5,7 +5,7 @@ export declare class RequestValidationError extends CustomError {
5
5
  statusCode: number;
6
6
  constructor(errors: ValidationError[]);
7
7
  serializeErrors(): {
8
- message: any;
8
+ msg: any;
9
9
  field: string;
10
10
  }[];
11
11
  }
@@ -29,7 +29,7 @@ var RequestValidationError = /** @class */ (function (_super) {
29
29
  }
30
30
  RequestValidationError.prototype.serializeErrors = function () {
31
31
  return this.errors.map(function (err) {
32
- return { message: err.msg, field: err.param };
32
+ return { msg: err.msg, field: err.param };
33
33
  });
34
34
  };
35
35
  return RequestValidationError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@munlib/common",
3
- "version": "1.0.113",
3
+ "version": "1.0.116",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",