Errors
Custom exception classes for the Ionworks API client.
Custom exception classes for the Ionworks API client.
This module defines IonworksError, which is raised when API requests
fail or return error responses.
-
exception ionworks.errors.IonworksError(message, status_code=None)[source]
Bases: Exception
Custom exception for Ionworks API errors.
- Parameters:
-
- Return type:
None
-
message
A string description of the error.
- Type:
str
-
data
Structured error data if available (e.g., from API error response).
- Type:
dict[str, Any] | None
-
status_code
HTTP status code if applicable.
- Type:
int | None
-
error_code
Machine-readable error code from the server (e.g., "NOT_FOUND").
- Type:
str | None
-
__init__(message, status_code=None)[source]
Initialize the IonworksError.
- Parameters:
message (str | dict[str, Any]) – Error message string or dict containing error details.
Supports both the legacy {"detail": ...} format and the new
standardized {"error_code": ..., "message": ..., "detail": ...}
format.
status_code (int | None) – Optional HTTP status code.
- Return type:
None