🐛 Fix invalid line id returned by /stop/{stop_id}/nextPassages endpoint

This commit is contained in:
2023-05-09 23:25:30 +02:00
parent de82eb6c55
commit ef26509b87
2 changed files with 5 additions and 5 deletions

View File

@@ -199,11 +199,12 @@ async def get_next_passages(stop_id: int) -> NextPassagesSchema | None:
# re.match will return None if the given journey.LineRef.value is not valid.
try:
line_id = IdfmInterface.LINE_RE.match(journey.LineRef.value).group(1)
except AttributeError as exc:
line_id_match = IdfmInterface.LINE_RE.match(journey.LineRef.value)
line_id = int(line_id_match.group(1)) # type: ignore
except (AttributeError, TypeError, ValueError) as err:
raise HTTPException(
status_code=404, detail=f'Line "{journey.LineRef.value}" not found'
) from exc
) from err
call = journey.MonitoredCall