Exemplo n.º 1
0
    def http_response(self, request, response):
        try:
            return HTTPErrorProcessor.http_response(self, request, response)
        except HTTPError as e:
            data = e.read()

            try:
                error_json = parse_json(data)
            except ValueError:
                logging.debug(
                    'Value error when trying to parse JSON from response data:\n%s'
                    % response)
                raise

            if e.code == 401:
                raise UnauthorizedError(error_json)
            elif e.code in (400, 500):
                raise BadRequestError(error_json)
            else:
                raise ClientException(error_json)
Exemplo n.º 2
0
 def http_response(self, request, response):
     if response.code in [200, 201, 204]:
         return response
     return HTTPErrorProcessor.http_response(self, request, response)
Exemplo n.º 3
0
 def http_response(self, request, response):
     return HTTPErrorProcessor.http_response(self, request, response)
Exemplo n.º 4
0
 def http_response(self, request, response):
     if response.code in [200, 201, 204]:
         return response
     return HTTPErrorProcessor.http_response(self, request, response)