How it works...
Compared to the previous recipe where we declared multiple errors, this declaration is much shorter and has several added benefits. The first benefit is that each error type can be created using the From trait (first IOError in step 4). Secondly, each type generates an automated description and Display implementation (see step 3, UnexpectedDeviceStateError, and then step 5) with the error's name. This is not perfect, but OK as a first step.
Under the hood, quick-error generates one enum that handles all possible cases and generates the implementations if necessary. Check out the main macro—quite impressive (http://tailhook.github.io/quick-error/quick_error/macro.quick_error.html)! To tailor the use of quick-error to your needs, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access