@munlib/common 1.0.121 → 1.0.124

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.
@@ -5,6 +5,6 @@ export declare class BadRequestError extends CustomError {
5
5
  constructor(msg: string, statusCode?: number);
6
6
  serializeErrors(): {
7
7
  msg: string;
8
- status: number;
9
- }[];
8
+ status: string;
9
+ };
10
10
  }
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.BadRequestError = void 0;
19
19
  var custom_error_1 = require("./custom-error");
20
+ var erroresStatus_1 = require("./erroresStatus");
20
21
  var BadRequestError = /** @class */ (function (_super) {
21
22
  __extends(BadRequestError, _super);
22
23
  function BadRequestError(msg, statusCode) {
@@ -28,7 +29,7 @@ var BadRequestError = /** @class */ (function (_super) {
28
29
  return _this;
29
30
  }
30
31
  BadRequestError.prototype.serializeErrors = function () {
31
- return [{ msg: this.message, status: this.statusCode }];
32
+ return { msg: this.message, status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()) };
32
33
  };
33
34
  return BadRequestError;
34
35
  }(custom_error_1.CustomError));
@@ -4,5 +4,6 @@ export declare abstract class CustomError extends Error {
4
4
  abstract serializeErrors(): {
5
5
  msg: string;
6
6
  field?: string;
7
- }[];
7
+ status: string;
8
+ };
8
9
  }
@@ -5,5 +5,6 @@ export declare class DatabaseConnectionError extends CustomError {
5
5
  constructor();
6
6
  serializeErrors(): {
7
7
  msg: string;
8
- }[];
8
+ status: string;
9
+ };
9
10
  }
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.DatabaseConnectionError = void 0;
19
19
  var custom_error_1 = require("./custom-error");
20
+ var erroresStatus_1 = require("./erroresStatus");
20
21
  var DatabaseConnectionError = /** @class */ (function (_super) {
21
22
  __extends(DatabaseConnectionError, _super);
22
23
  function DatabaseConnectionError() {
@@ -27,7 +28,7 @@ var DatabaseConnectionError = /** @class */ (function (_super) {
27
28
  return _this;
28
29
  }
29
30
  DatabaseConnectionError.prototype.serializeErrors = function () {
30
- return [{ msg: this.reason }];
31
+ return { msg: this.reason, status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()) };
31
32
  };
32
33
  return DatabaseConnectionError;
33
34
  }(custom_error_1.CustomError));
@@ -109,7 +109,12 @@ exports.errorCodes = {
109
109
  '500': 'Hubo un error en el servidor. Inténtelo más tarde.',
110
110
  '404': 'No se encontró el recurso solicitado.',
111
111
  '401': 'No tiene autorización para acceder a este recurso.',
112
- '400': 'La solicitud está mal formada o contiene datos inválidos.'
112
+ '400': 'La solicitud está mal formada o contiene datos inválidos.',
113
+ "ERR_BAD_REQUEST": "La solicitud fue malformada o contenía parámetros incorrectos.",
114
+ "ERR_NETWORK": "Hubo un problema de conexión con la red. Verifica tu conexión a internet o si el servidor está disponible.",
115
+ "ERR_BAD_RESPONSE": "El servidor respondió, pero la respuesta no fue válida o no fue lo que se esperaba.",
116
+ "ERR_TIMEOUT": "La solicitud tomó demasiado tiempo para completarse",
117
+ "ERR_CANCELED": "La solicitud fue cancelada antes de completarse.",
113
118
  };
114
119
  exports.statusCodeMapping = {
115
120
  "E000": "success",
@@ -221,7 +226,12 @@ exports.statusCodeMapping = {
221
226
  '500': 'error',
222
227
  '404': 'error',
223
228
  '401': 'error',
224
- '400': 'error'
229
+ '400': 'error',
230
+ "ERR_BAD_REQUEST": "error",
231
+ "ERR_NETWORK": "error",
232
+ "ERR_BAD_RESPONSE": "error",
233
+ "ERR_TIMEOUT": "error",
234
+ "ERR_CANCELED": "error"
225
235
  };
226
236
  var ErrorController = /** @class */ (function () {
227
237
  function ErrorController() {
@@ -3,6 +3,7 @@ export declare class NotAuthorizedError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
5
5
  serializeErrors(): {
6
+ status: string;
6
7
  msg: string;
7
- }[];
8
+ };
8
9
  }
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.NotAuthorizedError = void 0;
19
19
  var custom_error_1 = require("./custom-error");
20
+ var erroresStatus_1 = require("./erroresStatus");
20
21
  var NotAuthorizedError = /** @class */ (function (_super) {
21
22
  __extends(NotAuthorizedError, _super);
22
23
  function NotAuthorizedError() {
@@ -26,7 +27,7 @@ var NotAuthorizedError = /** @class */ (function (_super) {
26
27
  return _this;
27
28
  }
28
29
  NotAuthorizedError.prototype.serializeErrors = function () {
29
- return [{ msg: 'Token Not authorized' }];
30
+ return { status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()), msg: erroresStatus_1.ErrorController.getErrorMessage(this.statusCode.toString()) };
30
31
  };
31
32
  return NotAuthorizedError;
32
33
  }(custom_error_1.CustomError));
@@ -3,6 +3,7 @@ export declare class NotFoundError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
5
5
  serializeErrors(): {
6
+ status: string;
6
7
  msg: string;
7
- }[];
8
+ };
8
9
  }
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.NotFoundError = void 0;
19
19
  var custom_error_1 = require("./custom-error");
20
+ var erroresStatus_1 = require("./erroresStatus");
20
21
  var NotFoundError = /** @class */ (function (_super) {
21
22
  __extends(NotFoundError, _super);
22
23
  function NotFoundError() {
@@ -26,7 +27,7 @@ var NotFoundError = /** @class */ (function (_super) {
26
27
  return _this;
27
28
  }
28
29
  NotFoundError.prototype.serializeErrors = function () {
29
- return [{ msg: 'Not Found' }];
30
+ return { status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()), msg: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()) };
30
31
  };
31
32
  return NotFoundError;
32
33
  }(custom_error_1.CustomError));
@@ -8,5 +8,5 @@ export declare class RequestValidationError extends CustomError {
8
8
  status: string;
9
9
  msg: any;
10
10
  field: string;
11
- }[];
11
+ };
12
12
  }
@@ -29,10 +29,7 @@ var RequestValidationError = /** @class */ (function (_super) {
29
29
  return _this;
30
30
  }
31
31
  RequestValidationError.prototype.serializeErrors = function () {
32
- var _this = this;
33
- return this.errors.map(function (err) {
34
- return { status: erroresStatus_1.ErrorController.getGeneralStatus(_this.statusCode.toString()), msg: err.msg, field: err.param };
35
- });
32
+ return { status: erroresStatus_1.ErrorController.getGeneralStatus(this.statusCode.toString()), msg: this.errors[0].msg, field: this.errors[0].param };
36
33
  };
37
34
  return RequestValidationError;
38
35
  }(custom_error_1.CustomError));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@munlib/common",
3
- "version": "1.0.121",
3
+ "version": "1.0.124",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",