summaryrefslogtreecommitdiff
path: root/gitlab/exceptions.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/exceptions.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/exceptions.py')
-rw-r--r--gitlab/exceptions.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py
index 650328a..0822d3e 100644
--- a/gitlab/exceptions.py
+++ b/gitlab/exceptions.py
@@ -28,7 +28,12 @@ class GitlabError(Exception):
# Full http response
self.response_body = response_body
# Parsed error message from gitlab
- self.error_message = error_message
+ try:
+ # if we receive str/bytes we try to convert to unicode/str to have
+ # consistent message types (see #616)
+ self.error_message = error_message.decode()
+ except Exception:
+ self.error_message = error_message
def __str__(self):
if self.response_code is not None: