Skip to content

Commit

Permalink
UPDATE: use error handle
Browse files Browse the repository at this point in the history
Signed-off-by: Segelzwerg <25705862+Segelzwerg@users.noreply.github.com>
  • Loading branch information
Segelzwerg committed Sep 1, 2022
1 parent 8e2d182 commit e7f6770
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions whist_server/api/room/game.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Route of /room/game"""
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, status
from fastapi import APIRouter, BackgroundTasks, Depends, status
from whist_core.game.errors import HandNotDoneError

from whist_server.api.util import create_http_error
from whist_server.database.room import RoomInDb
from whist_server.services.channel_service import ChannelService
from whist_server.services.room_db_service import RoomDatabaseService
Expand Down Expand Up @@ -31,9 +32,5 @@ def next_hand(room_id: str, background_tasks: BackgroundTasks,
background_tasks.add_task(channel_service.notify(room_id, NextHandEvent()))
except HandNotDoneError as ready_error:
message = 'The hand is not done yet.'
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=message,
headers={"WWW-Authenticate": "Bearer"},
) from ready_error
raise create_http_error(message, status.HTTP_400_BAD_REQUEST) from ready_error
return {'status': 'Success'}

0 comments on commit e7f6770

Please sign in to comment.