How to use the routingpy.exceptions.RouterError function in routingpy

To help you get started, we’ve selected a few routingpy 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 gis-ops / routing-py / routingpy / routers / base.py View on Github external
try:
            body = response.json()
        except json.decoder.JSONDecodeError:
            raise exceptions.JSONParseError("Can't decode JSON response:{}".format(response.text))

        if status_code == 429:
            raise exceptions.OverQueryLimit(status_code, body)

        if 400 <= status_code < 500:
            raise exceptions.RouterApiError(status_code, body)

        if 500 <= status_code:
            raise exceptions.RouterServerError(status_code, body)

        if status_code != 200:
            raise exceptions.RouterError(status_code, body)

        return body
github gis-ops / routing-py / routingpy / exceptions.py View on Github external
class Timeout(Exception):  # pragma: no cover
    """The request timed out."""
    pass


class JSONParseError(Exception):  # pragma: no cover
    """The Json response can't be parsed.."""
    pass


class RetriableRequest(Exception):  # pragma: no cover
    """Signifies that the request can be retried."""
    pass


class OverQueryLimit(RouterError, RetriableRequest):
    """Signifies that the request failed because the client exceeded its query rate limit.

    Normally we treat this as a retriable condition, but we allow the calling code to specify that these requests should
    not be retried.
    """
    pass
github gis-ops / routing-py / routingpy / exceptions.py View on Github external
class RouterError(Exception):  # pragma: no cover
    """Represents an exception returned by the remote or local API."""
    def __init__(self, status, message=None):
        self.status = status
        self.message = message

    def __str__(self):
        if self.message is None:
            return self.status
        else:
            return "%s (%s)" % (self.status, self.message)


class RouterApiError(RouterError):
    """Represents an exception returned by a routing engine, i.e. 400 <= HTTP status code <= 500"""


class RouterServerError(RouterError):
    """Represents an exception returned by a server, i.e. 500 <= HTTP"""


class RouterNotFound(Exception):
    """Represents an exception raised when router can not be found by name."""


class Timeout(Exception):  # pragma: no cover
    """The request timed out."""
    pass
github gis-ops / routing-py / routingpy / exceptions.py View on Github external
def __init__(self, status, message=None):
        self.status = status
        self.message = message

    def __str__(self):
        if self.message is None:
            return self.status
        else:
            return "%s (%s)" % (self.status, self.message)


class RouterApiError(RouterError):
    """Represents an exception returned by a routing engine, i.e. 400 <= HTTP status code <= 500"""


class RouterServerError(RouterError):
    """Represents an exception returned by a server, i.e. 500 <= HTTP"""


class RouterNotFound(Exception):
    """Represents an exception raised when router can not be found by name."""


class Timeout(Exception):  # pragma: no cover
    """The request timed out."""
    pass


class JSONParseError(Exception):  # pragma: no cover
    """The Json response can't be parsed.."""
    pass