-
Notifications
You must be signed in to change notification settings - Fork 241
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: support Result
-based error handling in init methods
#754
Conversation
#[init(ignore_state)] | ||
#[return_result] | ||
pub fn new() -> Result<Self, &'static str> { } |
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.
Yeah, so this annotation is a bit misleading when used with init because nothing is actually returned. I wonder if there is a better name for this annotation.
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.
Yeah, not the best name for sure. How about #[handle_result_error]
or even #[handle_result]
?
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.
Yeah, not the best name for sure. How about
#[handle_result_error]
or even#[handle_result]
?
I personally like the latter since it's more concise (result_error is a bit redundant), but up to you!
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.
LGTM. And man they changed the Github Files changed
page 🙃
@ChaoticTempest haha, are you talking about the file tree view? I thought it was only available as a feature preview. Enabled it a few days ago and am very happy that they are finally adding something like this 😄 |
While refactoring lockable-ft example in #750 I realized that init methods could also benefit from
Result
-based error handling. Also realized that I forgot to throw an error when a method that does not returnResult
is marked with#[return_result]
.