Commit c52c82be authored by laodong's avatar laodong

fix exception issue

parent 151f2782
...@@ -91,6 +91,7 @@ class APIConnectionException(Exception): ...@@ -91,6 +91,7 @@ class APIConnectionException(Exception):
class APIRequestException(Exception): class APIRequestException(Exception):
def __init__(self, value): def __init__(self, value):
self.value = value self.value = value
super(Exception, self).__init__(value)
def __str__(self): def __str__(self):
return repr(self.value) return repr(self.value)
......
...@@ -36,7 +36,7 @@ class JPush(object): ...@@ -36,7 +36,7 @@ class JPush(object):
except requests.exceptions.ConnectTimeout: except requests.exceptions.ConnectTimeout:
raise common.APIConnectionException("Connection to api.jpush.cn timed out.") raise common.APIConnectionException("Connection to api.jpush.cn timed out.")
except Exception: except Exception:
raise common.APIConnectionException("Connection to api.jpush.cn error.") raise common.APIRequestException("Connection to api.jpush.cn error.")
logger.debug("Received %s response. Headers:\n\t%s\nBody:\n\t%s", response.status_code, '\n\t'.join( logger.debug("Received %s response. Headers:\n\t%s\nBody:\n\t%s", response.status_code, '\n\t'.join(
'%s: %s' % (key, value) for (key, value) in response.headers.items()), response.content) '%s: %s' % (key, value) for (key, value) in response.headers.items()), response.content)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment