Skip to content

Commit dfc4d29

Browse files
committed
fix(filter): replaced isHttpException with instanceof
1 parent 0415490 commit dfc4d29

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/filters/formatted-exception.filter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { FormattedException } from '../types/formatted-exception.interface';
33
import { Status } from '../types/status.enum';
44
import { HttpAdapterHost, Reflector } from '@nestjs/core';
55
import { FORMATTED_MESSAGE_METADATA } from '../constants';
6-
import { isHttpException } from '../utils/is-http-exception';
76

87
@Catch()
98
export class FormattedExceptionFilter<T> implements ExceptionFilter {
@@ -14,9 +13,9 @@ export class FormattedExceptionFilter<T> implements ExceptionFilter {
1413

1514
const ctx = host.switchToHttp();
1615

17-
const code = isHttpException(exception) ? (exception as HttpException).getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
16+
const code = exception instanceof HttpException ? (exception as HttpException).getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
1817

19-
const payload = isHttpException(exception) ? ((exception as HttpException).getResponse() as T) : null;
18+
const payload = exception instanceof HttpException ? ((exception as HttpException).getResponse() as T) : null;
2019

2120
const messages = exception instanceof Error ? this.reflector.get<string[]>(FORMATTED_MESSAGE_METADATA, exception.constructor) || (exception.message ? [exception.message] : []) : [];
2221

src/utils/is-http-exception.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)