graphprotocol / graphprotocol/graph-node

Add useful error messages/types to Result<T, ()>

Open
#3,247 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

error-handling good first issue
Dominant language
Rust
Stars
3.2k
Forks
1.1k
Avg merge
4d 1h
Merged PRs (30d)
1

Description

There are multiple functions that return Result<T, ()> in the code, this is equivalent to Option<T>, however instead of changing those to optional types, these should return useful error messages/types so it's easier to debug.

Example: https://github.com/graphprotocol/graph-node/blob/79390c39a13f166999ceea8defc55eedd05265ab/graph/src/data/subgraph/mod.rs#L169

Some of them could just return &str/String but preferably they should return a proper error type or just an instance of anyhow. If for any of them you decide to create new error types, consider using the crate thiserror 🙂

If you never used any of these crates mentioned above, take a look at our codebase, you'll find usages of both. And if you're doing something outside of the graph crate/folder, you might want to import those from it's prelude module.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with graph/src/data/subgraph/mod.rs at the linked example, then search the codebase for functions returning Result<T, ()>. Review existing usages of anyhow and thiserror, and map each candidate's failure cases before deciding on useful error messages or types. Done means the relevant unit-like results no longer discard error information across the identified code paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.