Skip to content

Commit 5b3bf57

Browse files
Merge pull request #228 from boostcampwm-2024/feature/#192
[Refactor] ๊ฒŒ์ž„์„œ๋ฒ„ ๋ชจ๋“ˆ, ๊ณ„์ธต ๋ฆฌํŒฉํ† ๋ง
2 parents 1c63568 + 08de193 commit 5b3bf57

12 files changed

+704
-578
lines changed

โ€Žpackages/backend/gameserver/src/app.module.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@ import { AuthModule } from './auth/auth.module';
33
import { GatewayModule } from './gateway/gateway.module';
44
import { RoomModule } from './room/room.module';
55
import { GameModule } from './game/game.module';
6-
import { ChatModule } from './chat/chat.module';
76
import { LoggerModule } from './logger/logger.module';
87
import { HttpLoggerMiddleware } from './middleware/http-logger.middleware';
98

109
@Module({
11-
imports: [
12-
LoggerModule,
13-
AuthModule,
14-
GatewayModule,
15-
RoomModule,
16-
GameModule,
17-
ChatModule,
18-
],
10+
imports: [LoggerModule, AuthModule, GatewayModule, RoomModule, GameModule],
1911
})
2012
export class AppModule implements NestModule {
2113
configure(consumer: MiddlewareConsumer) {

โ€Žpackages/backend/gameserver/src/chat/chat.module.ts

-8
This file was deleted.

โ€Žpackages/backend/gameserver/src/chat/chat.service.ts

-40
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Catch, ArgumentsHost } from '@nestjs/common';
2+
import { BaseWsExceptionFilter, WsException } from '@nestjs/websockets';
3+
import { Socket } from 'socket.io';
4+
import { LoggerService } from '../logger/logger.service';
5+
6+
@Catch()
7+
export class WebSocketExceptionFilter extends BaseWsExceptionFilter {
8+
constructor(private readonly logger: LoggerService) {
9+
super();
10+
}
11+
12+
catch(exception: Error, host: ArgumentsHost) {
13+
const client = host.switchToWs().getClient<Socket>();
14+
15+
let errorMessage: string;
16+
17+
if (exception instanceof WsException) {
18+
errorMessage = exception.message;
19+
} else {
20+
errorMessage = exception.message || '์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.';
21+
}
22+
23+
this.logger.logError('websocket', exception);
24+
25+
client.emit('error', { errorMessage });
26+
}
27+
}

0 commit comments

Comments
ย (0)