-
Notifications
You must be signed in to change notification settings - Fork 15
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
Return error when call was reverted #121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include some example? What's the context for using it? Isn't it equivalent to calling a method that returns Result<T, Err>
and asserting it's Err
?
@deuszx https://github.com/Cardinal-Cryptography/ink-exercises/blob/main/exercises/1-drink-test/tests/lib.rs#L61 it's not that straitghtforward - if your message returned |
drink/src/session.rs
Outdated
self.call_internal::<_, Result<(), E>>(None, message, args, endowment) | ||
.expect_err("Call should fail") | ||
.decode_revert::<Result<(), E>>() | ||
.expect("Call should be reverted") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we're loosing information - decode_revert
returns None
if the underlying error is different than CallReverted
. So, if it's anything else - we will fail on this expect and not provide any context for the developer to fix it.
Maybe, instead of returning Option
from decode_revert
, we could return a Result
and on the Err
side include the original error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.