Commit b6980b41 authored by Andrea Manzi's avatar Andrea Manzi
Browse files

FTS-1325: report reason for Unauthorized exception

parent 577a01f2
Pipeline #576336 passed with stage
in 1 minute and 18 seconds
...@@ -28,7 +28,13 @@ class BadEndpoint(FTS3ClientException): ...@@ -28,7 +28,13 @@ class BadEndpoint(FTS3ClientException):
class Unauthorized(FTS3ClientException): class Unauthorized(FTS3ClientException):
def __init__(self, reason):
self.reason = reason
def __str__(self): def __str__(self):
if self.reason:
return "Unauthorized: %s" % self.reason
else:
return "Unauthorized" return "Unauthorized"
......
...@@ -65,6 +65,9 @@ class Request(object): ...@@ -65,6 +65,9 @@ class Request(object):
else: else:
raise ClientError('Bad request') raise ClientError('Bad request')
elif 401 <= code <= 403: elif 401 <= code <= 403:
if message:
raise Unauthorized(message)
else:
raise Unauthorized() raise Unauthorized()
elif code == 404: elif code == 404:
raise NotFound(url, message) raise NotFound(url, message)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment