Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

how to chain nom::IError? #219

Open
bbigras opened this issue Sep 10, 2017 · 4 comments
Open

how to chain nom::IError? #219

bbigras opened this issue Sep 10, 2017 · 4 comments

Comments

@bbigras
Copy link

bbigras commented Sep 10, 2017

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
Copy link
Contributor

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

@bbigras
Copy link
Author

bbigras commented Sep 10, 2017

Thanks. I opened an issue for nom rust-bakery/nom#581.

@bbigras
Copy link
Author

bbigras commented Oct 30, 2017

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
Copy link
Contributor

No, sorry...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants