xyzspaces.exceptions module

This module defines API exceptions.

exception xyzspaces.exceptions.AuthenticationError[source]

Bases: Exception

Exception raised when authentication fails.

exception xyzspaces.exceptions.ApiError[source]

Bases: Exception

Exception raised for API HTTP response status codes not in [200…300).

The exception value will be the response object returned by requests which provides access to all its attributes, eg. status_code, reason and text, etc.

Example:

>>> try:
>>>     import os
>>>     os.environ["XYZ_TOKEN"] = "MY-XYZ-TOKEN"
>>>     api = HubApi()
>>>     api.get("/hub/nope").json()
>>> except ApiError as e:
>>>     resp = e.value.args[0]
>>>     if resp.status_code == 404 and resp.reason == "Not Found":
>>>         ...
__str__()[source]

Return a string from the HTTP response causing the exception.

The string simply lists the repsonse’s status code, reason and text content, separated with commas.

exception xyzspaces.exceptions.TooManyRequestsException[source]

Bases: Exception

Exception raised for API HTTP response status code 429.

This is a dedicated exception to be used with the backoff package, because it requires a specific exception class.

The exception value will be the response object returned by requests which provides access to all its attributes, eg. status_code, reason and text, etc.

__str__()[source]

Return a string from the HTTP response causing the exception.

The string simply lists the repsonse’s status code, reason and text content, separated with commas.