Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes handling of error responses #97

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auth0/v3/management/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def delete(self, url, params={}):
def _process_response(self, response):
text = json.loads(response.text) if response.text else {}

if isinstance(text, dict) and 'errorCode' in text:
if isinstance(text, dict) and 'error' in text:
raise Auth0Error(status_code=text['statusCode'],
error_code=text['errorCode'],
error_code=text['error'],
message=text['message'])
return text
8 changes: 4 additions & 4 deletions auth0/v3/test/management/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_get_errors(self, mock_get):
headers = {'Authorization': 'Bearer a-token'}

mock_get.return_value.text = '{"statusCode": 999,' \
' "errorCode": "code",' \
' "error": "code",' \
' "message": "message"}'

with self.assertRaises(Auth0Error) as context:
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_post_errors(self, mock_post):
rc = RestClient(jwt='a-token', telemetry=False)

mock_post.return_value.text = '{"statusCode": 999,' \
' "errorCode": "code",' \
' "error": "code",' \
' "message": "message"}'

with self.assertRaises(Auth0Error) as context:
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_patch_errors(self, mock_patch):
rc = RestClient(jwt='a-token', telemetry=False)

mock_patch.return_value.text = '{"statusCode": 999,' \
' "errorCode": "code",' \
' "error": "code",' \
' "message": "message"}'

with self.assertRaises(Auth0Error) as context:
Expand All @@ -124,7 +124,7 @@ def test_delete_errors(self, mock_delete):
rc = RestClient(jwt='a-token', telemetry=False)

mock_delete.return_value.text = '{"statusCode": 999,' \
' "errorCode": "code",' \
' "error": "code",' \
' "message": "message"}'

with self.assertRaises(Auth0Error) as context:
Expand Down