Skip to content

Improve error reporting in main entrypoint #100

@MegaRedHand

Description

@MegaRedHand

We have some unwraps/expects in the initialization code. We should replace them with static error handling, wrapping them with eyre in non-library code.

Some examples:

let config_yaml = std::fs::read_to_string(&config_path).expect("Failed to read config.yaml");
let genesis_config: GenesisConfig =
serde_yaml_ng::from_str(&config_yaml).expect("Failed to parse config.yaml");

The crate eyre, which we are using, has traits for wrapping errors that includes adding more information, like this example shows:

use eyre::{WrapErr, Result};

fn main() -> Result<()> {
    ...
    it.detach().wrap_err("Failed to detach the important thing")?;

    let content = std::fs::read(path)
        .wrap_err_with(|| format!("Failed to read instrs from {}", path))?;
    ...
}

We want to replace any panics in code with either eyre dynamic errors (for our main entrypoint and standalone binary), and thiserror enum messages for other crates. This issue is specifically for the main entrypoint (bin/ethlambda/).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions