Skip to main content

brainos_backends/
error.rs

1//! Typed errors for backend construction.
2//!
3//! Backends previously surfaced construction failures as `anyhow::Error`,
4//! which erased the failure mode for callers. Every backend constructor
5//! fails for exactly one reason — the underlying reqwest HTTP client can't
6//! be built — so a single typed variant captures it while letting callers
7//! match on it (and `anyhow`-using callers still get `?` via the
8//! `std::error::Error` impl).
9
10use thiserror::Error;
11
12/// Failure constructing a backend's HTTP client.
13#[derive(Debug, Error)]
14pub enum BackendInitError {
15    /// `reqwest::Client::builder().build()` failed. The first field labels
16    /// which backend (e.g. `"message client"`); the source is the reqwest
17    /// error.
18    #[error("{0} init failed: {1}")]
19    HttpClient(&'static str, #[source] reqwest::Error),
20}