[Rust 문서 읽기] 9. Error Handling (예외 처리)
The Rust Programming Language
- Recoverable and Unrecoverable errors
- recoverable error
- ex) file not found error
- type Result<T, E>
- unrecoverable error
- ex) index out of range, ...
- symptoms of bugs
- immediately stop the program
- Rust doesn't have exceptions
- panic! macro that stops execution when the program encounters an unrecoverable error
- Unrecoverable Errors with panic!
- Using a panic! Backtrace
- Backtrace is a list of all the functions that have been called to get to this point
- Recoverable Errors with Result
- Matching on Different Errors
- Shortcuts for Panic on Error: unwrap and expect
- Propagating Errors
- A Shortcut for Propagating Errors: the ? Operator
- Where The ? Operator Can Be Used
- To panic! or Not to panic!
- Examples, Prototype Code, and Tests
- Cases in Which You Have More Information Than the Compiler
- Guidelines for Error Handling
- Creating Custom Types for Validation
- Summary