Skip to content

feat: map the cases of an error enum to exception classes - #95

Closed
moetemp wants to merge 1 commit into
moe/up/resource-closefrom
moe/up/error-enums
Closed

moetemp wants to merge 1 commit into
moe/up/resource-closefrom
moe/up/error-enums

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds @nexus.error, which maps the cases of an error enum to exception classes.

/// @nexus.error details="stream-error-details" field="reason" name="stream-error"
///   python-extends="temporalio.exceptions.ApplicationError"
enum stream-error-reason {
  /// @nexus.fallback
  stream-error-reason-unspecified,
  /// @nexus.error
  stream-error-reason-not-found,
  /// @nexus.error retryable=true
  stream-error-reason-storage-unavailable,
}
  • Each marked case gets a class under one base. Another case, or one that this code doesn't know, raises the base class. An unknown number decodes as the @nexus.fallback case of feat: decode an unknown proto enum number as a marked fallback case temporalio/nexgen#321.
  • A class is non-retryable unless it has retryable=true. Its failure type is the class name, and its details hold the details record, so a Local Activity failure maps to the same class.
  • Python's calls convert a failure to the mapped class, in Workflow code and in a client. Go and Java ignore the directive with a warning.

TypeScript and .NET get the classes and the function that picks one. Their calls convert a failure in a follow-up PR.

Why?

The proposal raises one error class per Store reason, such as StreamNotFoundError. The facade maps the reasons by hand today.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

Python tests raise the mapped class from a client call and from a Local Activity failure. Python and TypeScript tests decode a reason that this code doesn't know from the wire, and get the base class.

`@nexus.error` on an enum makes a class per case of a failed call, under one base. Python's calls
raise the class of a failed call's reason from the original error.
@moetemp
moetemp force-pushed the moe/up/resource-close branch from 95b18f5 to c7e5e39 Compare November 5, 2026 22:22
@moetemp
moetemp force-pushed the moe/up/error-enums branch from 5d59255 to 09e7653 Compare November 5, 2026 22:22
@moetemp

moetemp commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Closing this. The Stream error classes move into sdk-python by hand, since StreamErrorDetails is a proto that the SDK already decodes. nexgen doesn't need @nexus.error.

@moetemp moetemp closed this Nov 6, 2026
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.

1 participant