-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
remove confusing panic messages from examples #2218
remove confusing panic messages from examples #2218
Conversation
woah, are all these failures my fault? |
The ci is broken on beta because of rust-lang/rust#66295 |
Could you rebase this to fix the CI? |
23b4f02
to
4980c9b
Compare
Done, I think :) |
.find(id) | ||
.first(&connection) | ||
.unwrap_or_else(|_| panic!("Unable to find post {}", id)); | ||
let post: Post = posts.find(id).first(&connection).unwrap(); |
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.
The error message was correct in that case, or do I miss something?
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.
uh, I might have been too quick there. let me look at it again.
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, sorry! Good catch! 😳
The `publish_post` examples contained a confusing `panic!()` that suggested the update statement would return an error, when a post to be updated could not be found. In reality, however, that case results in an `Ok(0)` value. To avoid confusion, this commit replaces the panicking `unwrap_or_else()` calls with a simpler `unwrap()`.
4980c9b
to
2e1f9e4
Compare
The
publish_post
examples contained a confusingpanic!()
thatsuggested the update statement would return an error, when a post to be
updated could not be found. In reality, however, that case results in an
Ok(0)
value.To avoid confusion, this commit replaces the panicking
unwrap_or_else()
calls with a simplerunwrap()
.