angzarr_client.errors¶
Error types for the Angzarr client library.
Audit finding #59 (structural error model). Every error carries:
A static
message— the same exact string for the same predicate failure across all call sites, suitable for log greppability, cross-language equality checks, and i18n keys.A stable
codeidentifier (SCREAMING_SNAKE) — programmatic dispatch and cucumber assertions key off this.Structured
details— runtime context (field name, type URL, domain, status code) that varies per call site.
Callers MUST NOT interpolate runtime values into message; that
defeats the static-string contract. Put runtime values in details.
Mirrors Rust’s CommandRejectedError / ClientError with the same
code values for cross-language symmetry.
Exceptions¶
Base class for client errors. |
|
Failed to establish connection to the server. |
|
Transport-level error. |
|
gRPC error from the server. |
|
Invalid argument provided by caller. |
|
Failed to parse timestamp. |
|
Command was rejected due to business rule violation. |
Module Contents¶
- exception angzarr_client.errors.ClientError(message: str, cause: Exception | None = None, *, code: str = '', details: collections.abc.Mapping[str, Any] | None = None)¶
Bases:
ExceptionBase class for client errors.
Predicate methods (
is_not_found,is_precondition_failed,is_invalid_argument,is_connection_error) returnFalsehere and are overridden by subclasses. This lets callers writeif err.is_not_found(): ...without casting.- Audit finding #59 fields:
message— static human-readable stringcode— SCREAMING_SNAKE stable identifierdetails— runtime context asdict[str, str]
Initialize self. See help(type(self)) for accurate signature.
- message¶
- code = ''¶
- cause = None¶
- exception angzarr_client.errors.ConnectionError(message: str = 'connection failed', *, code: str = 'CONNECTION_FAILED', details: collections.abc.Mapping[str, Any] | None = None)¶
Bases:
ClientErrorFailed to establish connection to the server.
Initialize self. See help(type(self)) for accurate signature.
- exception angzarr_client.errors.TransportError(cause: Exception, *, code: str = codes.TRANSPORT_ERROR, details: collections.abc.Mapping[str, Any] | None = None)¶
Bases:
ClientErrorTransport-level error.
Initialize self. See help(type(self)) for accurate signature.
- exception angzarr_client.errors.GRPCError(cause: grpc.RpcError, *, code: str = codes.GRPC_ERROR, details: collections.abc.Mapping[str, Any] | None = None)¶
Bases:
ClientErrorgRPC error from the server.
Initialize self. See help(type(self)) for accurate signature.
- property grpc_code: grpc.StatusCode¶
Return the gRPC status code.
- status() grpc.RpcError¶
Return the underlying gRPC RpcError (status).
- exception angzarr_client.errors.InvalidArgumentError(message: str, *, code: str = 'INVALID_ARGUMENT', details: collections.abc.Mapping[str, Any] | None = None)¶
Bases:
ClientErrorInvalid argument provided by caller.
Initialize self. See help(type(self)) for accurate signature.
- exception angzarr_client.errors.InvalidTimestampError(message: str = 'invalid timestamp', *, code: str = 'INVALID_TIMESTAMP', details: collections.abc.Mapping[str, Any] | None = None)¶
Bases:
ClientErrorFailed to parse timestamp.
Initialize self. See help(type(self)) for accurate signature.
- exception angzarr_client.errors.CommandRejectedError(message: str, status_code: str = 'FAILED_PRECONDITION', *, code: str = '', details: collections.abc.Mapping[str, Any] | None = None, cover: Any | None = None)¶
Bases:
ClientErrorCommand was rejected due to business rule violation.
- Status codes and retry semantics:
FAILED_PRECONDITION: state-based rejection; retryable after refreshing state.
INVALID_ARGUMENT: bad input; not retryable.
NOT_FOUND: aggregate does not exist; not retryable — refetching won’t help.
Audit finding #59: callers pass a static
message, a SCREAMING_SNAKEcode, and structureddetailskwargs. The factory methods (precondition_failed/invalid_argument/not_found) bind the appropriatestatus_code.The
coverattribute is the addressing envelope (domain,root,correlation_id,edition) of the command that produced this rejection. Handlers do not populate it; the router stamps it from the incomingCommandRequestat the dispatch boundary so every rejection is traceable to its originating workflow without each call site having to thread the context.Initialize self. See help(type(self)) for accurate signature.
- status_code = 'FAILED_PRECONDITION'¶
- cover = None¶
- static precondition_failed(code: str, message: str, details: collections.abc.Mapping[str, Any] | None = None) CommandRejectedError¶
Create a FAILED_PRECONDITION error for guard failures.
- Parameters:
code – SCREAMING_SNAKE stable identifier (use a constant from
angzarr_client.error_codes.codes).message – Static human-readable message (no interpolation; use a constant from
angzarr_client.error_codes.messages).details – Structured runtime context — keys should be from
angzarr_client.error_codes.keys.
- static invalid_argument(code: str, message: str, details: collections.abc.Mapping[str, Any] | None = None) CommandRejectedError¶
Create an INVALID_ARGUMENT error for input validation failures.
- static not_found(code: str, message: str, details: collections.abc.Mapping[str, Any] | None = None) CommandRejectedError¶
Create a NOT_FOUND error for missing-aggregate failures.