-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
anyhow::Error
in state generation functions (#264)
* Support `BlamedError<anyhow::Error>` `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. * Demonstrate `anyhow` support in an example * Support automatic conversion from `anyhow::Error` This makes `?` on an `anyhow::Error` work in a function returning `Result<S, BlamedError<anyhow::Error>>`.
- Loading branch information
Showing
4 changed files
with
15 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters