File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,17 @@ class ApiException(Exception):
99 @property
1010 def error (self ):
1111 """Returns the first argument used to construct this error."""
12- return self .args [0 ]
12+ return self .args [0 ]. get ( 'type' )
1313
1414 @property
1515 def message (self ):
1616 """Returns the second argument used to construct this error."""
17- return self .args [1 ]
17+ return self .args [0 ]. get ( 'message' )
1818
1919 @property
2020 def detail_message (self ):
2121 """Returns the third argument used to construct this error."""
22- return self .args [2 ]
22+ return self .args [0 ]. get ( 'detail_message' )
2323
2424
2525class UnauthorizedException (ApiException ):
Original file line number Diff line number Diff line change @@ -143,6 +143,17 @@ def test_api_errors(self):
143143 with self .assertRaises (ApiException ):
144144 self ._api .get ('/doesnotexist' )
145145
146+ def test_api_exception_properties (self ):
147+ with self .assertRaises (ApiException ) as e :
148+ self ._api .get ('/doesnotexist' )
149+ api_exception = e .exception
150+ self .assertEqual (api_exception .error ,
151+ 'NotFoundError' )
152+ self .assertEqual (api_exception .message ,
153+ 'The specified resource does not exist.' )
154+ self .assertIn ('Could not find resource for full path' ,
155+ api_exception .detail_message )
156+
146157 @unittest .skipIf (not PROXIES , "No proxies defined" )
147158 def test_get_with_proxy (self ):
148159 self ._api ._proxies = PROXIES
You can’t perform that action at this time.
0 commit comments