exceptions
exceptions ¶
The crew_dcs exception hierarchy.
Every error the library raises derives from DomoError, so a single
except DomoError catches anything crew_dcs throws — while each subclass
tells you which layer failed:
DomoError base — carries structured context (this module)
├── AuthError authentication / token failures
├── RouteError a Domo API returned an error response
│ ├── <Module>_GET_Error per-route-module retrieval failures
│ └── <Module>_CRUD_Error per-route-module write failures
├── TransportError no HTTP response at all (DNS, TLS, timeout)
└── ClassError entity-class (curated layer) failures
Defined in crew_dcs.client.get_data (also DomoError subclasses):
├── GetDataError Domo served an HTML block page (VPN/allowlist)
└── LooperError reserved for paginated-retrieval failures
What an exception carries¶
DomoError stores context as plain attributes instead of burying it in a
message string: status (HTTP code), entity_id / entity_name,
function_name / parent_class (where it was raised), domo_instance,
additional_context, and is_warning for non-fatal conditions. Its string
representation is assembled from whatever context is present.
RouteError (and AuthError) also keep the failed response as .res — a
crew_dcs.client.response.ResponseGetData — and mine it for you: when no
explicit message is passed, the constructor pulls message / error /
reason out of the API payload and copies status and domo_instance
off the response.
Catching¶
Catch at the granularity you can handle:
from crew_dcs.base.exceptions import DomoError, RouteError
from crew_dcs.routes.access_token import AccessToken_GET_Error, get_access_tokens
try:
res = await get_access_tokens(auth)
except AccessToken_GET_Error as e:
# one specific failure mode — full response still attached
print(e.status, e.res.response)
except RouteError as e:
# any API-layer failure
print(e.status, e.message)
except DomoError as e:
# anything crew_dcs raised, from any layer
print(e)
TransportError means the request never got a response (network-level),
and crew_dcs.client.get_data.GetDataError means Domo served an HTML
block page (VPN/allowlist) instead of JSON — both are distinct from a Domo
API that answered with an error status, which always surfaces as a
RouteError subclass.
AuthError ¶
AuthError(res: Any | None = None, **kwargs)
Bases: DomoError
Exception for authentication-related errors.
Source code in src/crew_dcs/base/exceptions.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
ClassError ¶
ClassError(
cls: Any = None,
cls_instance: Any = None,
entity_id_col: str | None = "id",
**kwargs,
)
Bases: DomoError
Exception for class-specific errors.
Source code in src/crew_dcs/base/exceptions.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
DomoError ¶
DomoError(
message: str | None = None,
exception: Exception | None = None,
entity_id: str | None = None,
entity_name: str | None = None,
function_name: str | None = None,
parent_class: str | None = None,
status: int | None = None,
domo_instance: str | None = None,
is_warning: bool = False,
additional_context: dict[str, Any] | None = None,
)
Bases: Exception
Base exception for all Domo-related errors.
This exception stores all relevant context as attributes and provides a clean string representation for logging and debugging.
Source code in src/crew_dcs/base/exceptions.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
RouteError ¶
RouteError(res: Any | None = None, **kwargs)
Bases: DomoError
Exception for API route/endpoint errors.
Source code in src/crew_dcs/base/exceptions.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |