We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← All tracks
0 / 4
Errors Are Values
RustReplace exceptions with types: `Option`, `Result`, `?` as a `From` conversion, error enums, `Display`/`Error` by hand, and when a panic is the correct answer.
This track is written for Rust, which isn't the mode you're browsing in.
0
/ 19 solved
· 5 articles
- 1. No null, no exceptions: Option and Result are just enums Read
- 2. Not solved yet. Matching on Option
- 3. Not solved yet. The Option combinator vocabulary
- 4. Not solved yet. Eager vs lazy defaults
- 5. Not solved yet. Borrowing through Option
- 6. Not solved yet. Mutating an Option in place
- 7. Not solved yet. Result, and why it is #[must_use]
- 8. Not solved yet. Result combinators and map_err
- 9. Not solved yet. Converting between Option and Result
- 10. The `?` operator, exactly Read
- 11. Not solved yet. Propagating with `?`
- 12. Not solved yet. `?` on Option, and bridging to Result
- 13. When panic! is correct, and when it is a bug Read
- 14. Not solved yet. Implementing std::error::Error
- 15. Not solved yet. From impls: the machinery behind `?`
- 16. Not solved yet. Error chains and source()
- 17. Error enums vs Box<dyn Error> Read
- 18. Not solved yet. Boxed errors and downcasting
- 19. Not solved yet. Adding context without anyhow
- 20. What thiserror and anyhow actually generate Read
- 21. Not solved yet. #[must_use] in depth
- 22. Not solved yet. Collecting an iterator of Results
- 23. Not solved yet. unwrap and expect discipline
- 24. Not solved yet. Documenting failure: # Errors and # Panics
Check yourself
4 questions · one attempt eachThese do not count toward finishing the track. They are here to catch the things that are easy to read past.
parse::<i32>() returns Result<i32, ParseIntError>, but the function returns Result<i32, MyErr>. Why does ? compile?
impl From<ParseIntError> for MyErr {
fn from(e: ParseIntError) -> Self { MyErr(format!("wrapped: {e}")) }
}
fn parse(s: &str) -> Result<i32, MyErr> {
Ok(s.parse::<i32>()? * 2)
}
Question 1 of 4