Skip to content

Commit

Permalink
fix(subway): error handling with skills learned by alien in the kaper…
Browse files Browse the repository at this point in the history
…-b66
  • Loading branch information
PleahMaCaka committed Nov 2, 2023
1 parent 36043a6 commit 9476cd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions routers/subway.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def request_subway_data(station_name: str):
station_name,
)
)

data = SubwayArrivalDto.from_json(json.loads(response.text))
data.items.sort(key=lambda x: x.pred_sec)
return data
try:
data = SubwayArrivalDto.from_json(json.loads(response.text))
data.items.sort(key=lambda x: x.pred_sec)
return data
except Exception as e:
print(F"역을 찾을 수 없습니다: {e}")
return None
2 changes: 1 addition & 1 deletion service/subway/dto/subway_arrival_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(

@classmethod
def from_json(cls, data: dict):
error_msg = data.get["errorMessage"]
error_msg = data["errorMessage"]
return cls(
error_msg=SubwayErrorMsgDto.from_json(
error_msg if error_msg is not None else data
Expand Down

0 comments on commit 9476cd6

Please sign in to comment.