filecheck icon indicating copy to clipboard operation
filecheck copied to clipboard

Provide std::error::Error impl for filecheck::Error

Open dtolnay opened this issue 6 years ago • 0 comments

filecheck::Error does not implement std::error::Error, which makes it unergonomic to use with modern error libraries that rely on that impl for error types.

use anyhow::Result;

fn f() -> Result<(), filecheck::Error> {
    Ok(())
}

fn main() -> Result<()> {
    f()?;  // doesn't work
    Ok(())
}
error[E0277]: the trait bound `filecheck::error::Error: std::error::Error` is not satisfied
 --> src/main.rs:8:8
  |
8 |     f()?;  // doesn't work
  |        ^ the trait `std::error::Error` is not implemented for `filecheck::error::Error`
  |
  = note: required because of the requirements on the impl of `std::convert::From<filecheck::error::Error>` for `anyhow::Error`
  = note: required by `std::convert::From::from

dtolnay avatar Nov 28 '19 06:11 dtolnay