Concept for Error handling

Hi there,
I'm still quite new to rust and I'm locking for a good concept to handle different Error Types.
The project contains different crates with create specific Errors and some custom Errors. These Errors I implemented with 'Impl Error for CustomError'. I want to Log the Errors and create a user-feedback in the main. So the plan is to bubble the Errors up to the main with Result<>'s.
Cause of the variety of Errors I'm using 'Box'.

So my questions:
I'm not sure if I should be a fan of Box What is your opinion about this?
Is there a nice concept/pattern I can use for programming this?
What is the Rust typical way to solve this?

Thx in advance
Karl

When dealing with errors I strongly recommend to use the anyhow crate (crates.io: Rust Package Registry) that takes care of all the gory details for you. Take a look, it changed my life :wink:

1 Like

thx,
this pushed me straight into the wright direction and lead me to some good articles.

3 Likes

Here's another more recent blog on the topic.[1]


  1. There are alternative means of construction than IIFEs. ↩ī¸Ž

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.