mirror of
https://github.com/rust-lang/rustlings
synced 2024-11-01 09:20:11 +00:00
b7ddd09fab
Adjust error text and naming to conform with best practices. Use `map_err()` instead of `or()`. Wrap lower-level errors instead of ignoring their details. Also, don't "cheat" by bypassing the `new()` function in tests. Fix a dangling reference in the try_from_into hints. |
||
---|---|---|
.. | ||
errors1.rs | ||
errors2.rs | ||
errors3.rs | ||
errors4.rs | ||
errors5.rs | ||
errors6.rs | ||
README.md |
Error handling
Most errors aren’t serious enough to require the program to stop entirely. Sometimes, when a function fails, it’s for a reason that you can easily interpret and respond to. For example, if you try to open a file and that operation fails because the file doesn’t exist, you might want to create the file instead of terminating the process.