How to use the bravado.exception.HTTPRedirection function in bravado

To help you get started, we’ve selected a few bravado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yelp / bravado / bravado / exception.py View on Github external
Return an HTTP exception class  based on the response. If a specific
    class doesn't exist for a particular HTTP status code, a more
    general :class:`HTTPError` class will be returned.
    :type response: :class:`bravado_core.response.IncomingResponse`
    :param message: Optional string message
    :param swagger_result: If the response for this HTTPError is
        documented in the swagger spec, then this should be the result
        value of the response.
    :return: An HTTP exception class that can be raised
    """
    status_code = response.status_code
    exc_class = status_map.get(status_code)

    if exc_class is None:
        exception_families = {
            300: HTTPRedirection,
            400: HTTPClientError,
            500: HTTPServerError,
        }
        exc_class = exception_families.get(
            (status_code // 100) * 100,
        ) or HTTPError

    return exc_class(response, message=message, swagger_result=swagger_result)
github Yelp / bravado / bravado / exception.py View on Github external
def __str__(self):
        # type: (...) -> str
        # Try to surface the most useful/relevant information available
        # since this is the first thing a developer sees when bad things
        # happen.
        status_and_reason = str(self.response)
        message = ': ' + self.message if self.message else ''
        text = ': ' + self.response.text if self.response.text else ''
        result = ': {0}'.format(self.swagger_result) \
            if self.swagger_result is not None else ''
        return '{0}{1}{2}{3}'.format(status_and_reason, message, text, result)


# The follow are based on the HTTP Status Code Registry at
# http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
class HTTPMultipleChoices(HTTPRedirection):
    """HTTP/300 - Multiple Choices"""
    status_code = 300


class HTTPMovedPermanently(HTTPRedirection):
    """HTTP/301 - Moved Permanently"""
    status_code = 301


class HTTPFound(HTTPRedirection):
    """HTTP/302 - Found"""
    status_code = 302


class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
github Yelp / bravado / bravado / exception.py View on Github external
return '{0}{1}{2}{3}'.format(status_and_reason, message, text, result)


# The follow are based on the HTTP Status Code Registry at
# http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
class HTTPMultipleChoices(HTTPRedirection):
    """HTTP/300 - Multiple Choices"""
    status_code = 300


class HTTPMovedPermanently(HTTPRedirection):
    """HTTP/301 - Moved Permanently"""
    status_code = 301


class HTTPFound(HTTPRedirection):
    """HTTP/302 - Found"""
    status_code = 302


class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
    status_code = 303


class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
    status_code = 304


class HTTPUseProxy(HTTPRedirection):
    """HTTP/305 - Use Proxy"""
github Yelp / bravado / bravado / exception.py View on Github external
class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
    status_code = 303


class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
    status_code = 304


class HTTPUseProxy(HTTPRedirection):
    """HTTP/305 - Use Proxy"""
    status_code = 305


class HTTPTemporaryRedirect(HTTPRedirection):
    """HTTP/307 - Temporary Redirect"""
    status_code = 307


class HTTPPermanentRedirect(HTTPRedirection):
    """HTTP/308 - Permanent Redirect"""
    status_code = 308


class HTTPBadRequest(HTTPClientError):
    """HTTP/400 - Bad Request"""
    status_code = 400


class HTTPUnauthorized(HTTPClientError):
    """HTTP/401 - Unauthorized"""
github Yelp / bravado / bravado / exception.py View on Github external
status_and_reason = str(self.response)
        message = ': ' + self.message if self.message else ''
        text = ': ' + self.response.text if self.response.text else ''
        result = ': {0}'.format(self.swagger_result) \
            if self.swagger_result is not None else ''
        return '{0}{1}{2}{3}'.format(status_and_reason, message, text, result)


# The follow are based on the HTTP Status Code Registry at
# http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
class HTTPMultipleChoices(HTTPRedirection):
    """HTTP/300 - Multiple Choices"""
    status_code = 300


class HTTPMovedPermanently(HTTPRedirection):
    """HTTP/301 - Moved Permanently"""
    status_code = 301


class HTTPFound(HTTPRedirection):
    """HTTP/302 - Found"""
    status_code = 302


class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
    status_code = 303


class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
github Yelp / bravado / bravado / exception.py View on Github external
class HTTPFound(HTTPRedirection):
    """HTTP/302 - Found"""
    status_code = 302


class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
    status_code = 303


class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
    status_code = 304


class HTTPUseProxy(HTTPRedirection):
    """HTTP/305 - Use Proxy"""
    status_code = 305


class HTTPTemporaryRedirect(HTTPRedirection):
    """HTTP/307 - Temporary Redirect"""
    status_code = 307


class HTTPPermanentRedirect(HTTPRedirection):
    """HTTP/308 - Permanent Redirect"""
    status_code = 308


class HTTPBadRequest(HTTPClientError):
    """HTTP/400 - Bad Request"""
github Yelp / bravado / bravado / exception.py View on Github external
class HTTPMultipleChoices(HTTPRedirection):
    """HTTP/300 - Multiple Choices"""
    status_code = 300


class HTTPMovedPermanently(HTTPRedirection):
    """HTTP/301 - Moved Permanently"""
    status_code = 301


class HTTPFound(HTTPRedirection):
    """HTTP/302 - Found"""
    status_code = 302


class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
    status_code = 303


class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
    status_code = 304


class HTTPUseProxy(HTTPRedirection):
    """HTTP/305 - Use Proxy"""
    status_code = 305


class HTTPTemporaryRedirect(HTTPRedirection):
    """HTTP/307 - Temporary Redirect"""
github Yelp / bravado / bravado / exception.py View on Github external
class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
    status_code = 304


class HTTPUseProxy(HTTPRedirection):
    """HTTP/305 - Use Proxy"""
    status_code = 305


class HTTPTemporaryRedirect(HTTPRedirection):
    """HTTP/307 - Temporary Redirect"""
    status_code = 307


class HTTPPermanentRedirect(HTTPRedirection):
    """HTTP/308 - Permanent Redirect"""
    status_code = 308


class HTTPBadRequest(HTTPClientError):
    """HTTP/400 - Bad Request"""
    status_code = 400


class HTTPUnauthorized(HTTPClientError):
    """HTTP/401 - Unauthorized"""
    status_code = 401


class HTTPPaymentRequired(HTTPClientError):
    """HTTP/402 - Payment Required"""
github Yelp / bravado / bravado / exception.py View on Github external
class HTTPMovedPermanently(HTTPRedirection):
    """HTTP/301 - Moved Permanently"""
    status_code = 301


class HTTPFound(HTTPRedirection):
    """HTTP/302 - Found"""
    status_code = 302


class HTTPSeeOther(HTTPRedirection):
    """HTTP/303 - See Other"""
    status_code = 303


class HTTPNotModified(HTTPRedirection):
    """HTTP/304 - Not Modified"""
    status_code = 304


class HTTPUseProxy(HTTPRedirection):
    """HTTP/305 - Use Proxy"""
    status_code = 305


class HTTPTemporaryRedirect(HTTPRedirection):
    """HTTP/307 - Temporary Redirect"""
    status_code = 307


class HTTPPermanentRedirect(HTTPRedirection):
    """HTTP/308 - Permanent Redirect"""