Surface download issue exceptions where appropriate instead of consuming them

This commit is contained in:
sfaulds 2016-11-14 11:00:26 +11:00
parent 1a8cbd7f99
commit ea3676eec0
2 changed files with 10 additions and 5 deletions

View File

@ -249,6 +249,7 @@ class DownloadUtils(object):
if action_type == "GET": if action_type == "GET":
raise Warning("Response Code 204: No Content for GET request") raise Warning("Response Code 204: No Content for GET request")
else: else:
# this is probably valid for DELETE and PUT
return None return None
elif response.status_code == requests.codes.ok: elif response.status_code == requests.codes.ok:
@ -266,15 +267,18 @@ class DownloadUtils(object):
except requests.exceptions.SSLError as error: except requests.exceptions.SSLError as error:
log.error("invalid SSL certificate for: %s", url) log.error("invalid SSL certificate for: %s", url)
raise
except requests.exceptions.ConnectTimeout as error: except requests.exceptions.ConnectTimeout as error:
log.error("Server timeout at: %s", url) log.error("Server timeout at: %s", url)
raise
except requests.exceptions.ConnectionError as error: except requests.exceptions.ConnectionError as error:
# Make the addon aware of status # Make the addon aware of status
if window('emby_online') != "false": if window('emby_online') != "false":
log.error("Server unreachable at: %s", url) log.error("Server unreachable at: %s", url)
window('emby_online', value="false") window('emby_online', value="false")
raise
except requests.exceptions.HTTPError as error: except requests.exceptions.HTTPError as error:
@ -301,7 +305,7 @@ class DownloadUtils(object):
elif (response.headers['X-Application-Error-Code'] == elif (response.headers['X-Application-Error-Code'] ==
"UnauthorizedAccessException"): "UnauthorizedAccessException"):
# User tried to do something his emby account doesn't allow # User tried to do something his emby account doesn't allow
pass raise Warning('UnauthorizedAccessException')
elif status not in ("401", "Auth"): elif status not in ("401", "Auth"):
# Tell userclient token has been revoked. # Tell userclient token has been revoked.
@ -314,6 +318,7 @@ class DownloadUtils(object):
except requests.exceptions.RequestException as error: except requests.exceptions.RequestException as error:
log.error("unknown error connecting to: %s", url) log.error("unknown error connecting to: %s", url)
raise
# something went wrong so return a None as we have no valid data # something went wrong so return a None as we have no valid data
return None return None

View File

@ -77,11 +77,11 @@ class UserClient(threading.Thread):
def verify_server(self): def verify_server(self):
url = "%s/emby/Users/Public?format=json" % self.get_server() try:
result = self.download(url, authenticate=False) url = "%s/emby/Users/Public?format=json" % self.get_server()
if result != "": # Specific verification, due to possibility of returning empty dict self.download(url, authenticate=False)
return True return True
else: except:
# Server connection failed # Server connection failed
return False return False