Chapter 7: Handling Errors in Rust and Rocket

In the previous chapter, we learned about creating endpoints and SQL queries to handle the management of the User entity. In this chapter, we are going to learn more about error handling in Rust and Rocket. After learning the concepts in this chapter, you will be able to implement error handling in a Rocket application.

We are also going to discuss more common ways to handle errors in Rust and Rocket, including signaling unrecoverable errors using the panic! macro and catching the panic! macro, using Option, using Result, creating a custom Error type, and logging the generated error.

In this chapter, we're going to cover the following main topics:

  • Using panic!
  • Using Option
  • Returning Result
  • Creating ...

Get Rust Web Development with Rocket now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.