Skip to content

Conversation

@VegetarianOrc
Copy link
Collaborator

@VegetarianOrc VegetarianOrc commented Jan 28, 2026

Summary

  • Add Failure base class for protocol-level failures with message, stack_trace, metadata, details, and cause fields
  • Update HandlerError and OperationError to inherit from Failure and set spec-compliant metadata/details automatically
  • HandlerError now accepts string error types and preserves the raw value when unknown types are received
  • Failure.stack_trace is a property that auto-captures the traceback when the exception is raised

Test plan

  • Run uv run pytest to verify all tests pass
  • Run poe lint to verify type checking and linting pass
  • Verify spec compliance for metadata (type: nexus.HandlerError / type: nexus.OperationError) and details fields

🤖 Generated with Claude Code

VegetarianOrc and others added 10 commits January 27, 2026 19:33
- 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
…match statement rather than the classvar frozensets.
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 <[email protected]>
- 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 <[email protected]>
@VegetarianOrc VegetarianOrc requested a review from a team as a code owner January 28, 2026 22:10
VegetarianOrc and others added 2 commits January 28, 2026 15:11
- 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 <[email protected]>
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 <[email protected]>
@VegetarianOrc VegetarianOrc marked this pull request as draft January 29, 2026 02:57
VegetarianOrc and others added 3 commits January 30, 2026 10:14
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants