File tree 3 files changed +18
-2
lines changed
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Custom exception classes for pyzootool
3
+ """
4
+
5
+ class ZooError (Exception ):
6
+
7
+ def __init__ (self , reason ):
8
+ self .reason = reason
9
+
10
+ def __unicode__ (self ):
11
+ return u'%s' % self .reason
12
+
13
+ def __str__ (self ):
14
+ return self .__unicode__ ()
15
+
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def parse_results(self, json_data):
32
32
self .tinyurl = json_data ['tinyurl' ]
33
33
self .thumbnail = json_data ['thumbnail' ]
34
34
except AttributeError :
35
- return None
35
+ raise error . ZooError ( "Failed to parse item json" )
36
36
37
37
class ZooItem ():
38
38
Original file line number Diff line number Diff line change 2
2
import urllib
3
3
4
4
from pyzootool import ROOT_URL
5
+ from pyzootool import error
5
6
6
7
class ZooUserResult ():
7
8
@@ -27,7 +28,7 @@ def parse_results(self, json_data):
27
28
self .avatar = json_data ['avatar' ]
28
29
self .profile = json_data ['profile' ]
29
30
except AttributeError :
30
- return None
31
+ raise error . ZooError ( "Failed to parse user json" )
31
32
32
33
class ZooUser ():
33
34
You can’t perform that action at this time.
0 commit comments