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.
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.
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,
Stringand support foranyhow::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. Theanyhow::Errorcan already convert any error type that implementedstd::error::Errortrait and support cause chain.It would make life easier for everyone if we could have that. Would even be better is consumer of
substreamsRust crate would not have to importanyhowin theirCargo.tomldirectly, I think we would need to re-exportanyhow::Errorout ofsubstreams-rsfor that so mapping code can still useResult<T, substreams::Error>but that would be actually aanyhow::Error.anyhow::Error?works correctly.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 supportinganyhow::Errorandstd::error:Errortrait.