diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-05-19 17:10:08 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2018-05-19 17:10:08 +0200 |
commit | fe89b949922c028830dd49095432ba627d330186 (patch) | |
tree | aa14611d11c550a790d7976f2b24fabb77e81a67 /gitlab/exceptions.py | |
parent | 701169441194bf0441cee13f2ab5784ffad7a207 (diff) | |
download | gitlab-fe89b949922c028830dd49095432ba627d330186.tar.gz |
Drop API v3 support
Drop the code, the tests, and update the documentation.
Diffstat (limited to 'gitlab/exceptions.py')
-rw-r--r-- | gitlab/exceptions.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py index 5825d23..744890f 100644 --- a/gitlab/exceptions.py +++ b/gitlab/exceptions.py @@ -197,43 +197,6 @@ class GitlabOwnershipError(GitlabOperationError): pass -def raise_error_from_response(response, error, expected_code=200): - """Tries to parse gitlab error message from response and raises error. - - Do nothing if the response status is the expected one. - - If response status code is 401, raises instead GitlabAuthenticationError. - - Args: - response: requests response object - error: Error-class or dict {return-code => class} of possible error - class to raise. Should be inherited from GitLabError - """ - - if isinstance(expected_code, int): - expected_codes = [expected_code] - else: - expected_codes = expected_code - - if response.status_code in expected_codes: - return - - try: - message = response.json()['message'] - except (KeyError, ValueError, TypeError): - message = response.content - - if isinstance(error, dict): - error = error.get(response.status_code, GitlabOperationError) - else: - if response.status_code == 401: - error = GitlabAuthenticationError - - raise error(error_message=message, - response_code=response.status_code, - response_body=response.content) - - def on_http_error(error): """Manage GitlabHttpError exceptions. |