The GBM Plus SDK raises typed exceptions fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/markzuckerbergas/gbmplus-api-python/llms.txt
Use this file to discover all available pages before exploring further.
gbmplus.exceptions so you can handle specific failure modes precisely in your code. Instead of catching a generic Exception, you can target exactly what went wrong — missing credentials, a failed login, an HTTP error from the API, or a malformed order — and respond accordingly.
All SDK exceptions inherit directly from Python’s built-in
Exception class, so they are fully compatible with standard try/except patterns and third-party error-tracking libraries.Exception types
| Exception | When it is raised |
|---|---|
UserError | At instantiation, when one or more of user_email, user_password, or client_id is missing (not passed and not set as an environment variable). |
AuthenticationError | When the SDK successfully sends credentials to the GBM+ auth endpoint but the server rejects them — wrong email, password, or client ID. |
APIError | On any HTTP error response from the GBM+ API (4XX or 5XX) after all retry attempts have been exhausted. Carries structured metadata about the failure. |
OrderFormatError | When generateOrderObject is called with trading_type=TradingTypes.Limited but no price argument is provided. |
APIError attributes
APIError exposes the following attributes for programmatic inspection:
| Attribute | Type | Description |
|---|---|---|
status | int | None | HTTP status code returned by the API (e.g. 404, 500). |
reason | str | None | HTTP reason phrase (e.g. "Not Found", "Internal Server Error"). |
message | dict | str | None | Parsed JSON body of the response, or the first 100 bytes of the raw content if the body is not valid JSON. |
tag | str | API section tag identifying the endpoint group (e.g. "accounts", "orders"). |
operation | str | Name of the operation that failed (e.g. "getAccounts", "placeOrder"). |
Importing exceptions
Import the exceptions you need directly fromgbmplus.exceptions:
Handling credential and auth errors
Credential and authentication errors are raised duringGBMPlusAPI() construction — before any API call is made. Wrap the instantiation in a try/except block to handle them gracefully:
Handling API errors
After a successful login, API calls can still fail due to network problems, invalid parameters, or server-side issues. Inspect theAPIError attributes to understand exactly what went wrong:
Handling order format errors
OrderFormatError is raised before any network call is made, when the SDK detects that your order parameters are logically inconsistent. The most common case is using TradingTypes.Limited without supplying a price:
Retry behaviour
The SDK has built-in automatic retry logic to handle transient failures without requiring any extra code from you.5XX server errors
When the GBM+ API returns a
5XX status code, the SDK waits 1 second and retries the request automatically. This happens up to maximum_retries times (default: 2). If all retries are exhausted, APIError is raised.Network exceptions
If a low-level
requests.exceptions.RequestException is raised (connection reset, DNS failure, etc.), the SDK applies the same 1-second wait and retry logic as for 5XX errors.