Map AioRpcError to Cadence Error Types#22
Merged
natemort merged 1 commit intocadence-workflow:mainfrom Sep 4, 2025
Merged
Conversation
87a3673 to
eba935f
Compare
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.
eba935f to
6b0aff9
Compare
shijiesheng
reviewed
Sep 3, 2025
| import grpc | ||
|
|
||
|
|
||
| class CadenceError(Exception): |
Member
There was a problem hiding this comment.
not sure if we should inherit RuntimeError or just Exception here. But it's ok to just land it now as we move forward
Member
Author
There was a problem hiding this comment.
https://docs.python.org/3/library/exceptions.html#Exception - "All user-defined exceptions should also be derived from this class.".
Simpler than Java, thankfully
shijiesheng
approved these changes
Sep 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
Why?
How did you test it?
Potential risks
Release notes
Documentation Changes