Skip to content

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

@maoueh

Description

@maoueh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions