In this chapter, we'll take a look at how unexpected situations are handled in Rust. Rust's error handling is based on generic types, such as Option and Result, which we saw in the previous chapter. There's also a mechanism called panicking, which is similar to exceptions, but unlike exceptions in other languages, panics are not used for recoverable error conditions.
The topics covered in this chapter include:
- The Option and Result types
- Matching against the Option and Result types
- Helper methods for handling errors
- The try! macro
- The ? operator
- Custom errors and the Error trait