Skip to content

error-stack: method cannot be called due to unsatisfied trait bounds #2659

Discussion options

You must be logged in to vote

I took a deeper look at your error message and it seems that you're using the fastwebsockets crate. I'm not going to judge their library design, but generally, returning Box<dyn Error + Send + Sync> is bad practice, especially for a library function. This makes it very hard to deal with errors as an application. the only real way to make the error usable again is something like:

pub struct MyError(Box<dyn Error + Send + Sync>);

impl fmt::Debug for MyError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Debug::fmt(&*self.0, f)
    }
}

impl fmt::Display for MyError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Display::fmt(&*self.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@TimDiekmann
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by TimDiekmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/libs > error-stack Affects the `error-stack` crate (library) area/libs Relates to first-party libraries/crates/packages (area)
2 participants