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,8 +28,14 @@ class BadEndpoint(FTS3ClientException):
class Unauthorized(FTS3ClientException):
def __init__(self, reason):
self.reason = reason
def __str__(self):
return "Unauthorized"
if self.reason:
return "Unauthorized: %s" % self.reason
else:
return "Unauthorized"
class ClientError(FTS3ClientException):
......
......@@ -65,7 +65,10 @@ class Request(object):
else:
raise ClientError('Bad request')
elif 401 <= code <= 403:
raise Unauthorized()
if message:
raise Unauthorized(message)
else:
raise Unauthorized()
elif code == 404:
raise NotFound(url, message)
elif code == 419:
......
Markdown is supported
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