Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit 2e48657

Browse files
authored
Fixed IndexError exception when station_name is not found
1 parent 8155e54 commit 2e48657

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mvg_api/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def get_id_for_station(station_name):
9999
If more than one station match, the first result is given.
100100
`None` is returned if no match was found.
101101
"""
102-
station = get_stations(station_name)[0]
102+
try:
103+
station = get_stations(station_name)[0]
104+
except IndexError:
105+
return None
103106
return station['id']
104107

105108

0 commit comments

Comments
 (0)