File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change
1
+ class Error (Exception ):
2
+ """General exception for package."""
3
+
4
+
5
+ class EntryCreatedError (Error ):
6
+ """Represents error in case no entry is created.
7
+
8
+ No 'id' in the json response.
9
+ """
10
+
11
+
12
+ class OperationCompletionError (Error ):
13
+ """Represents error in case of operation failure.
14
+
15
+ No 'msg' in the json response.
16
+ """
Original file line number Diff line number Diff line change 1
1
import json
2
2
3
+ from ..errors import EntryCreatedError , OperationCompletionError
4
+
3
5
4
6
class RS (object ):
5
7
def __init__ (self , raw ):
@@ -15,9 +17,8 @@ def __init__(self, raw):
15
17
def id (self ):
16
18
try :
17
19
return json .loads (self .raw )["id" ]
18
- except KeyError as error :
19
- error .message += "Raw: {0}" .format (self .raw )
20
- raise
20
+ except KeyError :
21
+ raise EntryCreatedError ("raw: {0}" .format (self .raw ))
21
22
22
23
def as_dict (self ):
23
24
return {"id" : self .id }
@@ -31,9 +32,8 @@ def __init__(self, raw):
31
32
def msg (self ):
32
33
try :
33
34
return json .loads (self .raw )["msg" ]
34
- except KeyError as error :
35
- error .message += "Raw: {0}" .format (self .raw )
36
- raise
35
+ except KeyError :
36
+ raise OperationCompletionError ("raw: {0}" .format (self .raw ))
37
37
38
38
def as_dict (self ):
39
39
return {"msg" : self .msg }
You can’t perform that action at this time.
0 commit comments