You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Failure base class with spec-compliant metadata/details (#45)
* Preserve raw HandlerError type
- Make raw_error_type optional in constructor, defaults to error_type.value
- Preserve raw_error_type separately to handle unknown types from the wire
- Remove unnecessary retryable_override property wrapper
- Update docstring examples to show from_error_type() as primary API
- Update usages to use from_error_type()
- Enhance tests with explicit assertions for error_type and raw_error_type
* Remove class methods and make constructor accept either a HandlerErrorType or a str to simplify the API surface
* Add additional assertions to string HanderError test
* Fix spacing in docstring
* Run formatter. Declare classvars in HandlerErrorType. Add ignore for inaccurate mypy linting error
* Update ruff and target python 3.10 for ruff linting. Swap to using a match statement rather than the classvar frozensets.
* Remove ruff from direct dependencies
* Add Failure base class and set spec-compliant metadata/details
Add Failure as a base class for HandlerError and OperationError,
representing protocol-level failures with message, stack_trace,
metadata, details, and cause fields.
Update HandlerError and OperationError to set their inherited Failure
metadata and details properties according to the spec representation:
- HandlerError: metadata["type"] = "nexus.HandlerError", details contains
"type" (error type) and optionally "retryableOverride"
- OperationError: metadata["type"] = "nexus.OperationError", details
contains "state" (failed/canceled)
User-provided metadata/details are merged but spec-required keys cannot
be overridden.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Make Failure.stack_trace a property that captures traceback
- Change stack_trace from a simple attribute to a property
- Return explicit stack_trace if provided, otherwise format __traceback__
- Return None when no stack trace is available (instead of empty string)
- Add docstring explaining the property behavior
- Add test verifying traceback capture for Failure, HandlerError, and OperationError
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Ignore IDE setting files in gitignore
* Add __repr__ methods and make metadata/details immutable
- Add __repr__ to Failure, HandlerError, and OperationError for debugging
- Make metadata and details immutable using MappingProxyType
- Change Failure.details type from Any to Mapping[str, Any] | None
- Add tests for explicit stack_trace precedence and immutability
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Use Python's native __cause__ for Failure exception chaining
Replace custom `cause` attribute with Python's built-in exception
chaining mechanism. This allows users to use standard Python syntax:
`raise Failure(...) from other_exception`
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Make Failure.stack_trace a plain attribute instead of a property
This allows consumers to distinguish between explicit stack traces
(from deserialization/remote sources) and local tracebacks (via
Python's native __traceback__).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Revert renaming of HandlerError.type
* Finish error_type -> type revert
* Fix HandlerError docstring to use 'type' parameter name
The docstring examples and :param documentation incorrectly referenced
'error_type' but the actual parameter is named 'type'. Updated docs
and __repr__ output to be consistent with the parameter name.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add default case to provide runtime default to retryable property
* Swap Failure to basic dataclass. Remove creation of details/metadata out of HandlerError and OperationError in favor of having the transport layer handle that as necessary.
* Fix linter errors and docstrings
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
0 commit comments