-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot define a custom error using thiserror
crate
#4
Comments
Thanks, will fix this when error is available in core. |
Out of curiosity, why do we need to wait until that issue will be closed? Can we use for now an intermediate solution? I am going to take Here how an error is handled An I can add |
I have never used This library is |
Ahh, if this library is considering even a In your opinion, what would a possible hack be to fix my problem? For now, I have introduced custom errors through As an alternative, I might also try snafu, an error handling library which also considers |
I'm only guessing but if it is the impl From<ParseError> for Error {
fn from(e: ParseError) -> Error {
Error::InvalidLicense(e)
}
} Or is it the |
Yep, in that case works, just wanted to use the |
The error I get with the src/error.rs:20:22
|
20 | InvalidLicense(#[from] license::ParseError),
| ^^^^ method cannot be called on `&ParseError` due to unsatisfied trait bounds
|
::: /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/license-3.2.0/src/lib.rs:159:1
|
159 | pub struct ParseError(());
| ---------------------
| |
| doesn't satisfy `ParseError: AsDynError<'_>`
| doesn't satisfy `ParseError: StdError`
|
= note: the following trait bounds were not satisfied:
`ParseError: StdError`
which is required by `ParseError: AsDynError<'_>`
`&ParseError: StdError`
which is required by `&ParseError: AsDynError<'_>` |
I'm trying to define a custom error through
thiserror
crate using this codebut it seems that
ParseError
cannot be retrieved using#[from]
attributeThe text was updated successfully, but these errors were encountered: