From 4a751fd2da352bcb94d5040c6795277835ac1a58 Mon Sep 17 00:00:00 2001 From: Neil Lawrence Date: Sat, 30 Nov 2013 11:02:42 +0000 Subject: [PATCH] Added some more error checking for downloading datasets. --- GPy/util/datasets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GPy/util/datasets.py b/GPy/util/datasets.py index b4a26636..7fd1b6c5 100644 --- a/GPy/util/datasets.py +++ b/GPy/util/datasets.py @@ -87,8 +87,11 @@ def download_url(url, store_directory, save_name = None, messages = True, suffix if not hasattr(e, "code"): raise response = e - if response.code == 404: - raise ValueError('Url ' + url + suffix + ' 404 not found.') + if response.code > 399 and response.code<500: + raise ValueError('Tried url ' + url + suffix + ' and received client error ' + str(response.code)) + elif response.code > 499: + raise ValueError('Tried url ' + url + suffix + ' and received server error ' + str(response.code)) + # if we wanted to get more sophisticated maybe we should check the response code here again even for successes. with open(save_name, 'wb') as f: f.write(response.read())