Permalink
Browse files

catching HTTPError in _request. return [0,<Error Message>] instead of…

… None
  • Loading branch information...
devendram committed Oct 19, 2012
1 parent ce07e0f commit edc25e7038f8aa74297305572d38c5309c445a70
Showing with 7 additions and 4 deletions.
  1. +7 −4 python/3.3/Pubnub.py
View
@@ -391,11 +391,14 @@ def _request( self, request, origin = None, encode = True, params = None ) :
## Send Request Expecting JSONP Response
try:
- try: usock = urllib2.urlopen( url, None, 200 )
- except TypeError: usock = urllib2.urlopen( url, None )
+ try:
+ usock = urllib2.urlopen( url, None, 200 )
+ except urllib2.HTTPError as e:
+ return [0, "HTTP Error, Status Code : " + str(e.getcode())]
+ except TypeError:
+ usock = urllib2.urlopen( url, None )
response = usock.read()
usock.close()
return json.loads( response )
except:
- return None
-
+ return [0,"Server Error"]

0 comments on commit edc25e7

Please sign in to comment.