# Error-chain is no longer maintained

**URL:** <https://users.rust-lang.org/t/error-chain-is-no-longer-maintained/27561>\
**Category:** announcements\
**Created:** [April 24, 2019, 8:35am UTC](https://users.rust-lang.org/t/error-chain-is-no-longer-maintained/27561 "2019-04-24T08:35:24Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![derekdreery](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/derekdreery/32/4788_2.png) [@derekdreery](https://users.rust-lang.org/u/derekdreery)\
**Post date:** [April 26, 2019, 7:57am UTC](https://users.rust-lang.org/t/error-chain-is-no-longer-maintained/27561/7 "2019-04-26T07:57:28Z")

</div>

I used to use error-chain and failure, but I tend to just write my errors directly now, so I have control over how they work. A simple error would be something like

```rust
#[derive(Debug)]
pub enum MyError {
    CannotOpenFile(io::Error),
    CannotReadData(io::Error),
    // ...
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            MyError::CannotOpenFile(e) => write!(f, "error while opening file: {}", e),
            // ....
        }
    }
}

impl Error for MyError {
    fn source(&self) -> &dyn Error {
        match self {
            MyError::CannotOpenFile(e) => e,
            // ...
        }
    }
}

```

You don't have to impl the source method if you think the fmt msg is enough, in which case you'd have

```rust
impl Error for MyError {}

```

which is a bit shorter 🙂

---

_[View the full topic](https://users.rust-lang.org/t/error-chain-is-no-longer-maintained/27561)._
