Skip to content

[metrics] charon-metrics public API uses anyhow::Result — pipeline cannot route metric errors #215

@obchain

Description

@obchain

Refs #50

File: crates/charon-metrics/src/lib.rs

Problem

charon-metrics public functions return anyhow::Result. The pipeline (charon-cli) cannot distinguish:

  • BindFailed: port in use, retry with different port or abort
  • TaskJoinError: HTTP server crashed, restart
  • ConfigInvalid: bad bind addr, abort

Same recurring pattern: PR #28, #39, #41, #43, #44 — all flagged. charon-metrics is the latest crate to repeat it.

Fix

Define structured error in lib.rs:

#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum MetricsError {
    #[error("bind failed on {addr}: {source}")]
    BindFailed { addr: String, #[source] source: std::io::Error },
    #[error("http server task panicked")]
    ServerPanicked,
    #[error("invalid bind address: {0}")]
    InvalidBindAddress(String),
}

Return Result<T, MetricsError> on all public fns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scopestatus:readyScoped and ready to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions