fiscalia_bo-nest-helpers 0.1.30 → 0.1.31
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,19 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
export declare class GlobalExceptionFilter implements ExceptionFilter {
|
3
|
-
catch(error: Error, host: ArgumentsHost): void;
|
4
|
-
}
|
1
|
+
import { HttpException } from '@nestjs/common';
|
5
2
|
export declare class MsSeguridadHttpError extends HttpException {
|
6
3
|
constructor(message?: string, status?: number, response?: any, error?: boolean);
|
7
4
|
}
|
8
|
-
export declare class ValidatorException extends HttpException {
|
9
|
-
constructor(message?: string, status?: number, response?: any, error?: boolean);
|
10
|
-
}
|
11
|
-
export declare class ApiBadRequestError extends BadRequestException {
|
12
|
-
constructor(message?: string, status?: number, response?: any, error?: boolean);
|
13
|
-
}
|
14
|
-
export declare class NotAcceptableError extends NotAcceptableException {
|
15
|
-
constructor(message?: string, status?: number, response?: any, error?: boolean);
|
16
|
-
}
|
17
|
-
export declare class ApiUnauthorizedError extends UnauthorizedException {
|
18
|
-
constructor(message?: string, response?: any, status?: number, error?: boolean);
|
19
|
-
}
|
@@ -1,126 +1,11 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
-
};
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
-
exports.
|
3
|
+
exports.MsSeguridadHttpError = void 0;
|
10
4
|
const common_1 = require("@nestjs/common");
|
11
|
-
const throttler_1 = require("@nestjs/throttler");
|
12
|
-
let GlobalExceptionFilter = class GlobalExceptionFilter {
|
13
|
-
catch(error, host) {
|
14
|
-
const response = host.switchToHttp().getResponse();
|
15
|
-
let resp = {
|
16
|
-
error: true,
|
17
|
-
message: 'Error interno del servidor',
|
18
|
-
response: null,
|
19
|
-
status: 500,
|
20
|
-
};
|
21
|
-
if (error.constructor.toString().includes('class BadRequestException')) {
|
22
|
-
resp.message = `Excepción de solicitud incorrecta, ${error.getResponse().message}`;
|
23
|
-
resp.status = 400;
|
24
|
-
}
|
25
|
-
else if (error instanceof common_1.NotFoundException) {
|
26
|
-
resp.message = 'No encontrado';
|
27
|
-
resp.status = 404;
|
28
|
-
}
|
29
|
-
else if (error instanceof throttler_1.ThrottlerException) {
|
30
|
-
resp.message = 'cantidad de peticiones excedidas';
|
31
|
-
resp.status = 429;
|
32
|
-
}
|
33
|
-
else if (error instanceof common_1.UnprocessableEntityException) {
|
34
|
-
resp.message = 'Entidad no processable';
|
35
|
-
resp.status = 422;
|
36
|
-
}
|
37
|
-
else if (error instanceof ValidatorException) {
|
38
|
-
resp.message = 'error de validación';
|
39
|
-
resp.status = 406;
|
40
|
-
}
|
41
|
-
else if (error instanceof NotAcceptableError) {
|
42
|
-
resp.message = 'no es posible procesar la solicitud';
|
43
|
-
resp.status = 406;
|
44
|
-
}
|
45
|
-
else if (error.constructor.toString().includes('class HttpException extends Error')) {
|
46
|
-
const respErr = error.getResponse();
|
47
|
-
if (typeof (respErr === null || respErr === void 0 ? void 0 : respErr.error) !== 'boolean' && typeof (respErr === null || respErr === void 0 ? void 0 : respErr.message) !== 'string') {
|
48
|
-
if (typeof respErr === 'string')
|
49
|
-
response.message = respErr;
|
50
|
-
}
|
51
|
-
else
|
52
|
-
resp = respErr;
|
53
|
-
if (!resp.status || resp.status < 200)
|
54
|
-
resp.status = 400;
|
55
|
-
}
|
56
|
-
else if (error instanceof MsSeguridadHttpError) {
|
57
|
-
const respErr = error.getResponse();
|
58
|
-
if (typeof (respErr === null || respErr === void 0 ? void 0 : respErr.error) !== 'boolean' && typeof (respErr === null || respErr === void 0 ? void 0 : respErr.message) !== 'string') {
|
59
|
-
if (typeof respErr === 'string')
|
60
|
-
response.message = respErr;
|
61
|
-
}
|
62
|
-
else
|
63
|
-
resp = respErr;
|
64
|
-
if (!resp.status || resp.status < 200)
|
65
|
-
resp.status = 400;
|
66
|
-
}
|
67
|
-
else if (error instanceof Error) {
|
68
|
-
const grpcParsingError = error;
|
69
|
-
if (grpcParsingError.code === 14 &&
|
70
|
-
grpcParsingError.details.includes('No connection established')) {
|
71
|
-
resp.message = 'Error al conectarse al servicio de GRPC';
|
72
|
-
resp.status = 422;
|
73
|
-
}
|
74
|
-
else if (grpcParsingError.code === 13 &&
|
75
|
-
grpcParsingError.details.includes('Response message parsing error:')) {
|
76
|
-
resp.message = 'Error al convertir las respuestas de GRPC';
|
77
|
-
resp.status = 422;
|
78
|
-
}
|
79
|
-
else if (grpcParsingError.code === 12 &&
|
80
|
-
grpcParsingError.details.includes('[object Object]')) {
|
81
|
-
resp.message =
|
82
|
-
'Error: el micro servicio de GRPC no tiene implementado este método o esta ignorado en MS-MYSQL.';
|
83
|
-
resp.status = 422;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
if (resp.status === 500 && resp.message === 'Error interno del servidor') {
|
87
|
-
console.error(error);
|
88
|
-
}
|
89
|
-
response.status(resp.status).json(resp);
|
90
|
-
}
|
91
|
-
};
|
92
|
-
GlobalExceptionFilter = __decorate([
|
93
|
-
(0, common_1.Catch)()
|
94
|
-
], GlobalExceptionFilter);
|
95
|
-
exports.GlobalExceptionFilter = GlobalExceptionFilter;
|
96
5
|
class MsSeguridadHttpError extends common_1.HttpException {
|
97
6
|
constructor(message = 'Ocurrió un error', status = 400, response = null, error = true) {
|
98
7
|
super({ error, message, status, response }, status);
|
99
8
|
}
|
100
9
|
}
|
101
10
|
exports.MsSeguridadHttpError = MsSeguridadHttpError;
|
102
|
-
class ValidatorException extends common_1.HttpException {
|
103
|
-
constructor(message = 'Ocurrió un error', status = 406, response = null, error = true) {
|
104
|
-
super({ error, message, status, response }, status);
|
105
|
-
}
|
106
|
-
}
|
107
|
-
exports.ValidatorException = ValidatorException;
|
108
|
-
class ApiBadRequestError extends common_1.BadRequestException {
|
109
|
-
constructor(message = 'Ocurrió un error', status = 400, response = null, error = true) {
|
110
|
-
super({ error, message, status, response });
|
111
|
-
}
|
112
|
-
}
|
113
|
-
exports.ApiBadRequestError = ApiBadRequestError;
|
114
|
-
class NotAcceptableError extends common_1.NotAcceptableException {
|
115
|
-
constructor(message = 'no es posible devolver datos por un error', status = 406, response = null, error = true) {
|
116
|
-
super({ error, message, status, response });
|
117
|
-
}
|
118
|
-
}
|
119
|
-
exports.NotAcceptableError = NotAcceptableError;
|
120
|
-
class ApiUnauthorizedError extends common_1.UnauthorizedException {
|
121
|
-
constructor(message = 'usuario no autenticado y/o token no válido', response = null, status = 401, error = true) {
|
122
|
-
super({ error, message, status, response });
|
123
|
-
}
|
124
|
-
}
|
125
|
-
exports.ApiUnauthorizedError = ApiUnauthorizedError;
|
126
11
|
//# sourceMappingURL=global-exception.filter.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../src/helpers/global-exception.filter.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"global-exception.filter.js","sourceRoot":"","sources":["../../src/helpers/global-exception.filter.ts"],"names":[],"mappings":";;;AAcA,2CAA+C;AAuF/C,MAAa,oBAAqB,SAAQ,sBAAa;IACrD,YAAY,OAAO,GAAG,kBAAkB,EAAE,MAAM,GAAG,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI;QACnF,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF;AAJD,oDAIC"}
|