@mondart/nestjs-common-module 2.1.2 → 2.1.3

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,7 +1,8 @@
1
1
  import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
2
  import { Response } from 'express';
3
3
  export declare class GlobalExceptionFilter implements ExceptionFilter {
4
- private sentryEnable;
4
+ private readonly logger;
5
+ private readonly sentryEnable;
5
6
  constructor(sentryEnable?: boolean);
6
7
  catch(exception: any, host: ArgumentsHost): import("rxjs").Observable<never> | Response<any, Record<string, any>>;
7
8
  private isObject;
@@ -19,18 +19,20 @@ const exceptions = require("@nestjs/common/exceptions");
19
19
  const Sentry = require("@sentry/nestjs");
20
20
  let GlobalExceptionFilter = class GlobalExceptionFilter {
21
21
  constructor(sentryEnable = false) {
22
+ this.logger = new common_1.Logger('GlobalExceptionFilter', {
23
+ timestamp: true,
24
+ });
22
25
  this.sentryEnable = sentryEnable;
23
26
  }
24
27
  catch(exception, host) {
25
28
  if (this.sentryEnable)
26
29
  Sentry.captureException(exception, exception?.response);
27
30
  const context = host.switchToHttp();
28
- const logger = new common_1.Logger('GlobalExceptionFilter', { timestamp: true });
29
31
  const type = host?.getType();
32
+ this.logger.error(`exceptionName: ${exception?.name}`, JSON.stringify(exception) ??
33
+ exception?.message ??
34
+ 'Unknown exception occurred.');
30
35
  if (type === 'rpc') {
31
- logger.error(`exceptionName: ${exception?.name}`, JSON.stringify(exception) ??
32
- exception?.message ??
33
- 'Unknown exception occurred.');
34
36
  const exceptionsName = Object.values(exceptions).map((exception) => exception.name);
35
37
  if (exceptionsName.includes(exception.name)) {
36
38
  return (0, rxjs_1.throwError)(exception);