error-chain icon indicating copy to clipboard operation
error-chain copied to clipboard

how to chain nom::IError?

Open bbigras opened this issue 8 years ago • 4 comments
trafficstars

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

bbigras avatar Sep 10 '17 03:09 bbigras

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

Yamakaky avatar Sep 10 '17 07:09 Yamakaky

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

bbigras avatar Sep 10 '17 17:09 bbigras

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!?

bbigras avatar Oct 30 '17 19:10 bbigras

No, sorry...

Yamakaky avatar Oct 30 '17 19:10 Yamakaky