Skip to main content

rtb_telemetry/
error.rs

1//! Typed errors for the telemetry subsystem.
2
3use miette::Diagnostic;
4use thiserror::Error;
5
6/// Failures surfaced by telemetry sinks.
7#[derive(Debug, Error, Diagnostic)]
8#[non_exhaustive]
9pub enum TelemetryError {
10    /// Sink I/O failure (disk write, HTTP round-trip, etc.).
11    #[error("sink I/O error: {0}")]
12    #[diagnostic(code(rtb::telemetry::io))]
13    Io(#[from] std::io::Error),
14
15    /// JSON (or other) serialisation failure.
16    #[error("serialisation error: {0}")]
17    #[diagnostic(code(rtb::telemetry::serde))]
18    Serde(String),
19
20    /// HTTP sink failure — bad endpoint, transport error, non-2xx
21    /// response. Details are already redacted by the sink.
22    #[error("HTTP telemetry sink error: {0}")]
23    #[diagnostic(code(rtb::telemetry::http))]
24    Http(String),
25
26    /// OTLP sink failure — pipeline build, export, or shutdown error.
27    #[error("OTLP telemetry sink error: {0}")]
28    #[diagnostic(code(rtb::telemetry::otlp))]
29    Otlp(String),
30}