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

Commit 7cc2390

Browse files
authored
Merge pull request #3 from LeMuecke/master
Return None instead of throwing an Index Error when station_name is not found
2 parents 8155e54 + 2e48657 commit 7cc2390

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)