rust-lang-deprecated / error-chain

Error boilerplate for Rust
Apache License 2.0
729 stars 111 forks source link

how to chain nom::IError? #219

Open bbigras opened 7 years ago

bbigras commented 7 years ago
foreign_links {
    Nom(::nom::IError);
    Io(::std::io::Error);
    ParseInt(::std::num::ParseIntError);
}
error[E0599]: no method named `cause` found for type `&nom::IError` in the current scope
  --> src/main.rs:56:5
   |
56 | /     error_chain! {
57 | |         foreign_links {
58 | |             Nom(::nom::IError);
59 | |             Io(::std::io::Error);
...  |
65 | |         }
66 | |     }
   | |_____^
   |
   = note: this error originates in a macro outside of the current crate

error[E0277]: the trait bound `nom::IError: std::fmt::Display` is not satisfied
  --> src/main.rs:56:5
   |
56 | /     error_chain! {
57 | |         foreign_links {
58 | |             Nom(::nom::IError);
59 | |             Io(::std::io::Error);
...  |
65 | |         }
66 | |     }
   | |_____^ `nom::IError` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
   |
   = help: the trait `std::fmt::Display` is not implemented for `nom::IError`
   = note: required because of the requirements on the impl of `std::fmt::Display` for `&nom::IError`
   = note: required by `std::fmt::Display::fmt`
   = note: this error originates in a macro outside of the current crate

error[E0277]: the trait bound `nom::IError: std::error::Error` is not satisfied
  --> src/main.rs:56:5
   |
56 | /     error_chain! {
57 | |         foreign_links {
58 | |             Nom(::nom::IError);
59 | |             Io(::std::io::Error);
...  |
65 | |         }
66 | |     }
   | |_____^ the trait `std::error::Error` is not implemented for `nom::IError`
   |
   = note: required by `std::error::Error::description`
   = note: this error originates in a macro outside of the current crate

error: aborting due to 3 previous errors
Yamakaky commented 7 years ago

You either have to ask nom devs to do the impl (should be OK) or use a errors {} block.

bbigras commented 7 years ago

Thanks. I opened an issue for nom https://github.com/Geal/nom/issues/581.

bbigras commented 6 years ago

The error-chain crate made some changes. Now I get:

the trait `std::convert::From<nom::Err<&str>>` is not implemented for `errors::Error`

but if I do:

error_chain! {
    foreign_links {
        Nom(::nom::Err<&str>);
    }
}

I get:

error[E0106]: missing lifetime specifier
  --> src/main.rs:14:28
   |
14 |             Nom(::nom::Err<&str>);
   |                            ^ expected lifetime parameter

Is there a way to specify a lifetime with error_chain!?

Yamakaky commented 6 years ago

No, sorry...