Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: must use CallExecution* type #150

Merged
merged 23 commits into from
Aug 30, 2022
Merged

feat: must use CallExecution* type #150

merged 23 commits into from
Aug 30, 2022

Conversation

ChaoticTempest
Copy link
Member

This is not necessarily an API-breaking change but semantically would change how errors are being bubbled up. This adds the #[must_use] to CallExecution* types so that the users are forced to handle it. The previous way of turning the CallExecution* type into a Result was not so great since we'd end up consuming the CallExecution* info along the way if a user wanted to handle the error but also have the details of the execution.

Added ok() and assert_ok() methods to use the CallExection* objects if the user does not care about the results contained within them. They'll still have access to the execution info regardless

@ChaoticTempest
Copy link
Member Author

This should also resolve #138 and #131

workspaces/src/worker/impls.rs Outdated Show resolved Hide resolved
workspaces/tests/optional_args.rs Outdated Show resolved Hide resolved
workspaces/src/result.rs Outdated Show resolved Hide resolved
workspaces/src/result.rs Outdated Show resolved Hide resolved
workspaces/src/result.rs Outdated Show resolved Hide resolved
workspaces/src/result.rs Outdated Show resolved Hide resolved
Base automatically changed from feat/error-handling to main August 9, 2022 15:58
@ChaoticTempest
Copy link
Member Author

@itegulov @austinabell Let me know what you guys think of this now. CallExecutionDetails just has executed() so people can forward the errors up for convenience, ok()/err() to explicitly handle the errors with the details included

workspaces/src/result.rs Outdated Show resolved Hide resolved
workspaces/src/result.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

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

Going to open another issue because the types that are forwarded from the RPC types seem very unintuitive to use. So unclear how to proceed, for example, we are awaiting transactions to be fully completed, but we still have the intermediate execution statuses nested within the CallExecutionDetails structure.

Opened issue: #183

workspaces/src/result.rs Outdated Show resolved Hide resolved
workspaces/src/result.rs Outdated Show resolved Hide resolved
@ChaoticTempest
Copy link
Member Author

New changes based on #183. Also took the liberty of renaming CallExecution* to be just Execution* since they're not purely just execution details from a call.

So after this, we have ExecutionFinalResult to allow us to do into_result() -> Result<ExecutionSuccess, ExecutionFailure>. Also note that I had ExecutionFinalResult could have just been a type alias of ExecutionFinalResult like the Success and Failure types, but #[must_use] would end up being applied to success/failure types as well which wasn't ideal.

Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

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

handling execution errors there definitely seems like an improvement, just left some comments for small questions about details.

workspaces/src/result.rs Outdated Show resolved Hide resolved
workspaces/src/error/impls.rs Outdated Show resolved Hide resolved
@ChaoticTempest
Copy link
Member Author

@austinabell think we should be good to go with this one. I'll merge this one right now, and if there's anymore concern, we can address in another PR

@ChaoticTempest ChaoticTempest merged commit c7f09dc into main Aug 30, 2022
@ChaoticTempest ChaoticTempest deleted the feat/error-must-use branch August 30, 2022 21:01
@frol frol mentioned this pull request Oct 4, 2023
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.

3 participants