Errors in Rust are of two kinds, recoverable and unrecoverable. For unrecoverable errors, the panic! macro gets invoked. This video explores how you can use it to handle errors.
- [Instructor] Rust's commitment to reliability…extends to error handling.…Errors are a fact of life in software,…so Rust has a number of features…for handling situations in which something goes wrong.…Rust groups errors into two major categories:…Recoverable and unrecoverable errors.…Recoverable errors are situations…in which it's reasonable to report…the problem to the user, and retry the operation,…like a file not found error.…Unrecoverable errors are always symptoms…of bugs, like trying to access…a location beyond the end of an area.…
Rust has to type result for recoverable errors,…and panic! macro for unrecoverable errors,…that stops execution when it encounters…unrecoverable errors.…Sometimes, bad things happen in your code,…and there's nothing you can do about it.…In these cases, Rust has the panic! macro.…When the panic! macro executes,…your program will print a failure message,…unwind, and clean up the stack, and then quit.…The most common situation this occurs in…is when a bug of some kind has been detected,…
- Installing Rust
- Data types
- Adjusting memory allocation
- Setting up race conditions
- Working with functions
- Exploring references and borrowing
- Using structs
- Method syntax
- Demonstrating recoverable errors with Result
- Working with enums
- Getting user input
Skill Level Beginner
1. Hello, Rust!
2. Basic Programming Concepts
3. Ownership in Rust
4. Data Handling and Pattern Matching in Rust
5. Error Handling
6. Sample Rust Project: The Guessing Game
Next steps1m 14s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.