This chapter covers
- Setting up the project structure
- Basics of error handling in Rust and Actix Web
- Defining a custom error handler
- Error handling for retrieving all courses
- Error handling for retrieving course details
- Error handling for posting a new course
- Summary
In the previous chapter, we wrote the code to post and retrieve courses through an API. But what we demonstrated and tested were the happy path scenarios. In the real world however, many types of failures can occur. The database server may be unavailable, the tutor id provided in request may be invalid, there may be a web server error, and so on. It is important that our web service is able to detect the errors , handle them gracefully and send a meaningful error message back to the user or client sending the API request. This is done through error handling, which is the focus of this chapter. Error handling is important not just for stability of our web service, but also to provide a good user experience.