Skip to content
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

Ensure that we are able to properly propagate error in Substreams #14

Open
3 tasks
maoueh opened this issue Feb 1, 2023 · 0 comments
Open
3 tasks

Ensure that we are able to properly propagate error in Substreams #14

maoueh opened this issue Feb 1, 2023 · 0 comments

Comments

@maoueh
Copy link
Contributor

maoueh commented Feb 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants