I have a type Foo whose methods may "raise" errors of an associated type Foo::Err.
pub trait Foo {
type Err;
You should use a trait object Error, and you return the first error that you encounter:
pub trait Bar {
fn bar(&mut self, foo: F) -> Result>;
}
or implement your trait like this:
impl Bar for MyType {
type Err = Box;
fn bar(&mut self, foo: F) -> Result;
}
If you really want to have your two errors (but this is strange because one error suffices to make the process not ok), you can use a crate like failure to create an "error trace".
As a general advice, you should not forget to use the traits from std to add more semantic to your code.