-
Notifications
You must be signed in to change notification settings - Fork 87
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
Support anyhow::Error
in state generation functions
#264
Conversation
CI failures:
|
Oh this is great, thank you so much! Those CI failures are normal at this point, don't worry about them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good to me!
`anyhow::Error` cannot implement `std::error::Error` (see dtolnay/anyhow#136), which Perseus requires for errors returned from state generation functions. But Perseus immediately boxes the error, and `anyhow::Error` does support conversion into `Box<dyn std::error::Error>`. So if we make the conversion from `BlamedError` to `GenericBlamedError` more general, `BlamedError<anyhow::Error>` works. This change should be backwards-compatible because Rust has an impl `From<E> for Box<dyn Error + Send + Sync + 'a>`. That impl should match all error types previously accepted by Perseus, and is sufficient to still accept them after this change.
This makes `?` on an `anyhow::Error` work in a function returning `Result<S, BlamedError<anyhow::Error>>`.
Force-pushed to sign the commits (no content changes). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good to merge!
anyhow::Eror
in state generation functionsanyhow::Error
in state generation functions
Extends #264 for head, headers, build paths, etc.
By generalizing the supported errors in state generation from types that directly implement
std::error::Error
to types that can be converted into a boxedstd::error::Error
, we can makeanyhow::Error
work.I first tried to support just
anyhow::Error
specifically (in addition to the already-supported error types), but the compiler does not easily allow that: it thinksanyhow::Error
might implementstd::error::Error
in the future, so it will not let me implement things on both. Please make sure the broader support for error types this adds is reasonable (and that I am correct about this change being backwards-compatible) before merging.