Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Commit

Permalink
* rename ApplicationExceptionFilter -> AppExceptionFilter
Browse files Browse the repository at this point in the history
* rename WebsocketsExceptionFilter -> WsExceptionFilter
  • Loading branch information
Chanlito committed Mar 11, 2018
1 parent c4d2130 commit 2699f65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/exception/app-exception.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Catch, ExceptionFilter, HttpStatus } from '@nestjs/common';
import { Logger } from '../logger';

@Catch()
export class ApplicationExceptionFilter implements ExceptionFilter {
export class AppExceptionFilter implements ExceptionFilter {
constructor(private readonly logger?: Logger) {}

catch(err: any, res: any) {
Expand Down Expand Up @@ -32,10 +32,11 @@ export class ApplicationExceptionFilter implements ExceptionFilter {
res.status(statusCode).json(responseBody);

if (this.logger) {
const msg = `[AppExceptionFilter] ${responseBody.message}`;
if (statusCode >= 500) {
this.logger.error(responseBody, responseBody.message);
this.logger.error(responseBody, msg);
} else {
this.logger.warn(responseBody, responseBody.message);
this.logger.warn(responseBody, msg);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/exception/ws-exception.filter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Catch, WsExceptionFilter } from '@nestjs/common';
import { Catch, WsExceptionFilter as NestWsExceptionFilter } from '@nestjs/common';
import { WsException } from '@nestjs/websockets';

@Catch(WsException)
export class WebsocketsExceptionFilter implements WsExceptionFilter {
export class WsExceptionFilter implements NestWsExceptionFilter {
catch(exception: WsException, socket: any) {
socket.emit('exception', {
status: 'exception',
Expand Down

0 comments on commit 2699f65

Please sign in to comment.