-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Right now, it's not easily possible to perform error propagation up to the the Substreams module because the handler module return error is Substreams specific and don't offer conversion from other errors today.
We could add conversion for most standard error, String and support for anyhow::Error, I imagine it will enable error propagation in almost very cases, and cases failing to compile could workaround by wrapping their error with anyhow.
We should actually instead start this task by investigating returning Result<T, anyhow::Error> directly instead. The anyhow::Error can already convert any error type that implemented std::error::Error trait and support cause chain.
It would make life easier for everyone if we could have that. Would even be better is consumer of substreams Rust crate would not have to import anyhow in their Cargo.toml directly, I think we would need to re-export anyhow::Error out of substreams-rs for that so mapping code can still use Result<T, substreams::Error> but that would be actually a anyhow::Error.
- Investigate what is the impact of changing mapper so that the error type is actually
anyhow::Error - Ensure that error propagation with
?works correctly. - Update documentation and CHANGELOG
If we find out that Result<T, anyhow::Error> creates issue, we would go back to keeping actual Substreams error type and implement a bunch of conversion, specially supporting anyhow::Error and std::error:Error trait.