otlp_arrow_library/
error.rs

1//! Error types for OTLP Arrow Library
2//!
3//! Defines all error types used throughout the library with clear error messages
4//! and context for debugging.
5
6use thiserror::Error;
7
8/// Main error type for the OTLP Arrow Library
9#[derive(Error, Debug)]
10pub enum OtlpError {
11    /// Configuration-related errors
12    #[error("Configuration error: {0}")]
13    Config(#[from] OtlpConfigError),
14
15    /// Export/processing errors
16    #[error("Export error: {0}")]
17    Export(#[from] OtlpExportError),
18
19    /// I/O errors
20    #[error("I/O error: {0}")]
21    Io(#[from] std::io::Error),
22
23    /// Server-related errors
24    #[error("Server error: {0}")]
25    Server(#[from] OtlpServerError),
26}
27
28/// Configuration-related errors
29#[derive(Error, Debug)]
30pub enum OtlpConfigError {
31    /// Invalid output directory path
32    #[error("Invalid output directory: {0}")]
33    InvalidOutputDir(String),
34
35    /// Invalid interval value
36    #[error("Invalid interval: {0}")]
37    InvalidInterval(String),
38
39    /// Missing required configuration field
40    #[error("Missing required field: {0}")]
41    MissingRequiredField(String),
42
43    /// Invalid URL format
44    #[error("Invalid URL format: {0}")]
45    InvalidUrl(String),
46
47    /// Configuration validation failed
48    #[error("Configuration validation failed: {0}")]
49    ValidationFailed(String),
50}
51
52/// Export/processing errors
53#[derive(Error, Debug)]
54pub enum OtlpExportError {
55    /// Message buffer is full
56    #[error("Message buffer is full")]
57    BufferFull,
58
59    /// Serialization error
60    #[error("Serialization error: {0}")]
61    SerializationError(String),
62
63    /// Remote forwarding error
64    #[error("Remote forwarding failed: {0}")]
65    ForwardingError(String),
66
67    /// Arrow IPC conversion error
68    #[error("Arrow IPC conversion error: {0}")]
69    ArrowConversionError(String),
70
71    /// Cleanup error
72    #[error("Cleanup error: {0}")]
73    CleanupError(String),
74
75    /// Format conversion error
76    #[error("Format conversion error: {0}")]
77    FormatConversionError(String),
78}
79
80/// Server-related errors
81#[allow(clippy::enum_variant_names)]
82#[derive(Error, Debug)]
83pub enum OtlpServerError {
84    /// Failed to bind server address
85    #[error("Failed to bind server address: {0}")]
86    BindError(String),
87
88    /// Failed to start server
89    #[error("Failed to start server: {0}")]
90    StartupError(String),
91
92    /// Server shutdown error
93    #[error("Server shutdown error: {0}")]
94    ShutdownError(String),
95}
96
97impl From<anyhow::Error> for OtlpError {
98    fn from(err: anyhow::Error) -> Self {
99        OtlpError::Io(std::io::Error::other(err.to_string()))
100    }
101}