Error

"the trait bound Error is not satisfied" — How to Fix

Fix the 'trait bound Error is not satisfied' error by implementing the std::error::Error trait for your custom type.

The error occurs because your type does not implement the std::error::Error trait required by the context. Implement the trait for your error type to satisfy the bound.

use std::fmt;

#[derive(Debug)]
struct MyError;

impl fmt::Display for MyError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "something went wrong")
    }
}

impl std::error::Error for MyError {}