TrainsAndRoads/app/src/exceptions.ts

30 lines
719 B
TypeScript

import { WsException } from '@nestjs/websockets';
import { ErrorCode } from 'interface';
export abstract class WebSocketException extends WsException {
public readonly errorCode: ErrorCode;
constructor(message: string, errorCode: ErrorCode) {
super(message);
this.errorCode = errorCode;
}
}
export class PlayerNotFoundException extends WebSocketException {
constructor(playerId: string) {
super(
'Unable to find player from ID: ' + playerId,
ErrorCode.PLAYER_NOT_FOUND,
);
}
}
export class GameNotFoundException extends WebSocketException {
constructor(gameId: string) {
super(
'Unable to find game from ID: ' + gameId,
ErrorCode.GAME_NOT_FOUND,
);
}
}