summaryrefslogtreecommitdiff
path: root/gitlab/__init__.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-11-24 17:37:10 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2018-11-24 17:37:10 +0100
commit1fb1296c9191e57e109c4e5eb9504bce191a6ff1 (patch)
tree4f4ec9107f47dd518460636e539a5adc548880ca /gitlab/__init__.py
parent011274e7f94519d30dee59f5448215838d058e37 (diff)
downloadgitlab-refactor/excpetion_msg.tar.gz
Improve error message handling in exceptionsrefactor/excpetion_msg
* Depending on the request Gitlab has a 'message' or 'error' attribute in the json data, handle both * Add some consistency by converting messages to unicode or str for exceptions (depending on the python version) Closes #616
Diffstat (limited to 'gitlab/__init__.py')
-rw-r--r--gitlab/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 99ff5c5..477d564 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -490,10 +490,14 @@ class Gitlab(object):
time.sleep(wait_time)
continue
+ error_message = result.content
try:
- error_message = result.json()['message']
+ error_json = result.json()
+ for k in ('message', 'error'):
+ if k in error_json:
+ error_message = error_json[k]
except (KeyError, ValueError, TypeError):
- error_message = result.content
+ pass
if result.status_code == 401:
raise GitlabAuthenticationError(