Properly handle stop not found
This commit is contained in:
parent
819b56e89b
commit
7e765fe94a
1 changed files with 5 additions and 2 deletions
7
main.py
7
main.py
|
@ -66,12 +66,12 @@ async def stop(
|
||||||
if passages_res.status_code != 200:
|
if passages_res.status_code != 200:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=passages_res.status_code,
|
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:
|
if infos_res.status_code != 200:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=infos_res.status_code,
|
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}
|
stop_ids = {monitored_stop_id}
|
||||||
|
@ -86,6 +86,9 @@ async def stop(
|
||||||
passages[(ligne, destination)].append(passage.get("delaipassage"))
|
passages[(ligne, destination)].append(passage.get("delaipassage"))
|
||||||
stop_ids.add(destination)
|
stop_ids.add(destination)
|
||||||
|
|
||||||
|
if not passages:
|
||||||
|
raise HTTPException(status_code=404, detail="Stop not found")
|
||||||
|
|
||||||
stop_infos: Dict[int, Stop] = {}
|
stop_infos: Dict[int, Stop] = {}
|
||||||
for info in infos_res.json().get("values"):
|
for info in infos_res.json().get("values"):
|
||||||
stop_id = info.get("id")
|
stop_id = info.get("id")
|
||||||
|
|
Reference in a new issue