Creating and wrapping errors is a common task in modern programs. However, as we have seen in various recipes in this chapter, it can be quite tedious to handle every possible case and, on top of that, care about each possible variation that might be returned. This problem is well known and the Rust community has come up with ways to make that a lot easier. We'll touch on macros in the next chapter (Chapter 6, Expressing Yourself with Macros), but creating error types leans a lot on using macros. Additionally, this recipe mirrors a previous recipe (Handling multiple errors) to show the differences in code.
Working with external crates for error handling
How to do it...
Let's pull in some external crates to handle...