Properly handle stop not found

This commit is contained in:
Gabriel Augendre 2021-11-14 12:29:58 +01:00
parent 819b56e89b
commit 7e765fe94a
1 changed files with 5 additions and 2 deletions

View File

@ -66,12 +66,12 @@ async def stop(
if passages_res.status_code != 200:
raise HTTPException(
status_code=passages_res.status_code,
detail="HTTP error during call to remote API",
detail="HTTP error during call to remote passages API",
)
if infos_res.status_code != 200:
raise HTTPException(
status_code=infos_res.status_code,
detail="HTTP error during call to remote API",
detail="HTTP error during call to remote info API",
)
stop_ids = {monitored_stop_id}
@ -86,6 +86,9 @@ async def stop(
passages[(ligne, destination)].append(passage.get("delaipassage"))
stop_ids.add(destination)
if not passages:
raise HTTPException(status_code=404, detail="Stop not found")
stop_infos: Dict[int, Stop] = {}
for info in infos_res.json().get("values"):
stop_id = info.get("id")