Skip to content

Commit

Permalink
Added code to generate better error message
Browse files Browse the repository at this point in the history
When the link to the Springer Excel file is broken,
it generates human friendly message.
  • Loading branch information
chaosAD committed May 8, 2020
1 parent a57be56 commit 02b3339
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@
table = 'table_' + table_url.split('/')[-1] + '.xlsx'
table_path = os.path.join(folder, table)
if not os.path.exists(table_path):
books = pd.read_excel(table_url)
try:
books = pd.read_excel(table_url)
except (OSError, IOError) as e:
if e.__class__.__name__ == 'HTTPError' and e.getcode() == 404:
print('Error: {} URL page not found. '.format(table_url) +
'Please contact intelligent human for help.')
else:
print(e)
exit(-1)
# Save table in the download folder
books.to_excel(table_path)
else:
Expand Down

0 comments on commit 02b3339

Please sign in to comment.