-
Notifications
You must be signed in to change notification settings - Fork 80
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
modules: Change *Reader
traits to return Result
instead of Option
#73
Comments
I think we need discussion because this proposal affects many IBC handlers. What do you think? |
Your proposal is sound. Our current approach using return values consisting of an Would you like to take a stab at starting to implement the necessary modifications for a simple Context, e.g., |
This is a question. I'd like to know how to add errors for other failures to the error list. I tried to add a read failure with std error. It looks wrong. I want to give any error to this error, e.g. my storage error. What should I do? ReadFailure
[ std::error::Error ]
| e | {
format_args!("Reading an object failed with reason: {}", e.to_string())
}, |
Try this: ReadFailure
[ DisplayOnly<Box<dyn std::error::Error + Send + Sync>> ]
| e | {
format_args!("Reading an object failed, reason: {}", e)
}, |
Context
reader returns Result
ibc
*Reader
traits to return Result
instead of Option
ibc
*Reader
traits to return Result
instead of Option
*Reader
traits to return Result
instead of Option
Add missing comma
Crate
ibc
Summary
The functions of the module readers in contexts (e.g.
ClientReader
) can returnResult
instead ofOption
.Problem Definition
Most of the readers get a module or state from the storage. These operations could fail, e.g. DB failure. A reader function returns just
None
in this case for now. It looks difficult to handle the failure.For example, when initializing a connection,
ClientReader
returnsNone
due to a temporary DB error. It can be done by just retrying the initialization. If the reader returnsNone
because the corresponding client state doesn't exist, we need to create a client at first. IfResult
returns, we can handle the failure more clearly.Proposal
The functions of the module readers return
Result
instead ofOption
Acceptance Criteria
Readers returns
Result
For Admin Use
The text was updated successfully, but these errors were encountered: