Skip to content

Commit

Permalink
adding error handler for incorrect server response
Browse files Browse the repository at this point in the history
  • Loading branch information
luiscape committed Aug 30, 2015
1 parent d0675d3 commit d0b0810
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/station_collector/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ def FetchLatestStationData(verbose=True):
# TODO: make this URL relative.
#
u = 'http://www.citibikenyc.com/stations/json'
r = requests.get(u)

#
# At times, server returns wrong encoding.
# This makes sure that the server doesn't
# crash.
#
try:
r = requests.get(u)

except Exception as e:
print '%s Something went wrong checking for data.' % item('prompt_error')
return False

if not r.ok:
print '%s Something went wrong checking for data.' % item('prompt_error')
Expand Down

0 comments on commit d0b0810

Please sign in to comment.