Skip to content

Conversation

@natemort
Copy link
Member

@natemort natemort commented Sep 3, 2025

What changed?

  • Introduce a set of Exceptions mapping to Cadence Error types and raise those from RPCs.

Why?

  • This makes error handling much more straightforward and inline with the other clients. Extracting error details from an AioRpcError is rather verbose and error-prone, and it makes it difficult to handle only specific exception scenarios. Cadence has a number of common expected errors, such as WorkflowExecutionAlreadyStartedError.

How did you test it?

  • Unit test that creates a fake server returning errors.

Potential risks

Release notes

Documentation Changes

@natemort natemort changed the title Client error Map AioRpcError to Cadence Error Types Sep 3, 2025
Introduce Python exception types that correspond to the Errors returned as details on GRPC. Following Python best practices the type names end with `Error` and we include all arguments in the `Exception` `args` tuple. For the sake of convenient we additionally set them as fields.

This makes error handling much more straightforward and inline with the other clients. Extracting error details from an AioRpcError is rather verbose and error-prone, and it makes it difficult to handle only specific exception scenarios. Cadence has a number of common expected errors, such as WorkflowExecutionAlreadyStartedError.

In order to map from AioRpcError to these specific types, introduce a new interceptor. GRPC interceptors must return a correct `Call` type (which is awaitable), so create a wrapper `UnaryUnaryCall` that can translate the exception type once it completes.
import grpc


class CadenceError(Exception):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we should inherit RuntimeError or just Exception here. But it's ok to just land it now as we move forward

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.python.org/3/library/exceptions.html#Exception - "All user-defined exceptions should also be derived from this class.".

Simpler than Java, thankfully

@natemort natemort merged commit ced4570 into cadence-workflow:main Sep 4, 2025
3 checks passed
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