feat: Add Recover with async extensions and tests#151
Open
mark-pro wants to merge 2 commits intoamantinband:mainfrom
Open
feat: Add Recover with async extensions and tests#151mark-pro wants to merge 2 commits intoamantinband:mainfrom
mark-pro wants to merge 2 commits intoamantinband:mainfrom
Conversation
Author
|
The new Recover feature is useful as we use this library actively and often have to recreate the extension in several times over. I am open to suggestions and comments or name changes to |
Author
|
After looking at the open PRs I noticed there is a very similar PR (#149) to extend |
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.
Currently, there is no way to provide alternative branching logic when there is a failure. That is, there is no way to recover. Think
cache miss -> call db.To address the gap a new "Recover" feature can be added to the
ErrorOrlibrary, allowing consumers to handle error states by providing recovery logic, both synchronously and asynchronously. The changes include the implementation ofRecoverandRecoverAsyncmethods, extension methods for use withTask<ErrorOr<TValue>>, comprehensive documentation updates, and unit tests to ensure correct behavior.In more complex scenarios where the errors need to be inspected for the path the consumer can do the following:
New Recover Feature Implementation:
RecoverandRecoverAsyncmethods toErrorOr<TValue>, allowing users to recover from errors by providing custom logic to handle error states.Task<ErrorOr<TValue>>to support fluent async recovery withRecoverandRecoverAsync.Documentation Updates:
README.mdto document the newRecoverandRecoverAsyncmethods, including usage examples and updates to feature-mixing sections. [1] [2]Testing:
ErrorOr.RecoverTests.csto verify the behavior of the synchronousRecovermethod and its extension.ErrorOr.RecoverAsyncTests.csto verify the behavior of the asynchronousRecoverAsyncmethod and its extension.