Error Handling

When an API request fails, quadriga.exceptions.RequestError is raised. The exception object contains the error message, error code and HTTP request response details.

Example:

from quadriga import QuadrigaClient
from quadriga.exceptions import RequestError

client = QuadrigaClient(
    api_key='api_key',
    api_secret='api_secret',
    client_id='client_id',
)
try:
    client.get_balance()    # Fails due to invalid credentials
except RequestError as err:
    err.message             # Error message
    err.url                 # API endpoint
    err.body                # Raw response body from QuadrigaCX
    err.headers             # Response headers
    err.http_code           # HTTP status code
    err.error_code          # Error code from QuadrigaCX
    err.response            # requests.Response object
    err.response.request    # requests.Request object

Exceptions

Below are exceptions raised by quadriga client.

exception quadriga.exceptions.InvalidCurrencyError

Raised when an invalid major currency is given.

exception quadriga.exceptions.InvalidOrderBookError

Raised when an invalid order book is given.

exception quadriga.exceptions.QuadrigaError

Base (catch-all) client exception.

exception quadriga.exceptions.RequestError(response, message, error_code=None)

Raised when an API request to QuadrigaCX fails.

Variables:
  • message (str | unicode) – Error message.
  • url (str | unicode) – QuadrigaCX API endpoint.
  • body (str | unicode) – Raw response body from QuadrigaCX.
  • headers (requests.structures.CaseInsensitiveDict) – Response headers.
  • http_code (int) – HTTP status code.
  • error_code (int) – Error code from QuadrigaCX.
  • response (requests.Response) – Response object.