@mondart/nestjs-common-module 1.1.34 → 1.1.36
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,8 +1,6 @@
|
|
|
1
1
|
import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { ConfigService } from '@nestjs/config';
|
|
4
3
|
export declare class GlobalExceptionFilter implements ExceptionFilter {
|
|
5
|
-
|
|
6
|
-
constructor(configService: ConfigService);
|
|
4
|
+
constructor();
|
|
7
5
|
catch(exception: any, host: ArgumentsHost): import("rxjs").Observable<never> | Response<any, Record<string, any>>;
|
|
8
6
|
}
|
|
@@ -11,26 +11,25 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.GlobalExceptionFilter = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
14
|
const rxjs_1 = require("rxjs");
|
|
16
15
|
const dto_1 = require("../dto");
|
|
17
16
|
const enums_1 = require("../enums");
|
|
18
17
|
const helpers_1 = require("../helpers");
|
|
19
18
|
let GlobalExceptionFilter = class GlobalExceptionFilter {
|
|
20
|
-
constructor(
|
|
21
|
-
this.configService = configService;
|
|
22
|
-
}
|
|
19
|
+
constructor() { }
|
|
23
20
|
catch(exception, host) {
|
|
24
21
|
const context = host.switchToHttp();
|
|
25
22
|
const logger = new common_1.Logger('GlobalExceptionFilter', { timestamp: true });
|
|
26
23
|
const type = host?.getType();
|
|
27
24
|
if (type === 'rpc') {
|
|
28
25
|
try {
|
|
29
|
-
logger.error(exception
|
|
30
|
-
|
|
26
|
+
logger.error(typeof exception, JSON.stringify(exception) ??
|
|
27
|
+
exception?.message ??
|
|
28
|
+
'Unknown exception occurred.');
|
|
29
|
+
return (0, rxjs_1.throwError)(() => exception ?? new Error('Unknown exception occurred.'));
|
|
31
30
|
}
|
|
32
31
|
catch (err) {
|
|
33
|
-
return (0, rxjs_1.throwError)(() =>
|
|
32
|
+
return (0, rxjs_1.throwError)(() => new common_1.InternalServerErrorException(enums_1.SharedMessages.INTERNAL_SERVER_ERROR));
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
if (type === 'http') {
|
|
@@ -72,5 +71,5 @@ let GlobalExceptionFilter = class GlobalExceptionFilter {
|
|
|
72
71
|
exports.GlobalExceptionFilter = GlobalExceptionFilter;
|
|
73
72
|
exports.GlobalExceptionFilter = GlobalExceptionFilter = __decorate([
|
|
74
73
|
(0, common_1.Catch)(),
|
|
75
|
-
__metadata("design:paramtypes", [
|
|
74
|
+
__metadata("design:paramtypes", [])
|
|
76
75
|
], GlobalExceptionFilter);
|