steer_tui/
error.rs

1//! Error types for the steer-tui crate
2
3use std::io;
4use thiserror::Error;
5
6/// Result type alias for steer-tui operations
7pub type Result<T> = std::result::Result<T, Error>;
8
9/// Main error type for steer-tui
10#[derive(Error, Debug)]
11pub enum Error {
12    /// Terminal I/O errors
13    #[error("Terminal I/O error: {0}")]
14    Io(#[from] io::Error),
15
16    /// Event processing errors
17    #[error("Event processing error: {0}")]
18    EventProcessing(String),
19
20    /// UI rendering errors
21    #[error("UI rendering error: {0}")]
22    Rendering(String),
23
24    /// Channel communication errors
25    #[error("Channel error: {0}")]
26    Channel(String),
27
28    /// Invalid state errors
29    #[error("Invalid UI state: {0}")]
30    InvalidState(String),
31
32    /// Model selection errors
33    #[error("Model selection error: {0}")]
34    ModelSelection(String),
35
36    /// Notification errors
37    #[error("Notification error: {0}")]
38    Notification(String),
39
40    /// Command processing errors
41    #[error("Command processing error: {0}")]
42    CommandProcessing(String),
43
44    /// Timeout errors
45    #[error("Operation timed out: {0}")]
46    Timeout(String),
47
48    /// Core errors from steer-core
49    #[error("Core error: {0}")]
50    Core(#[from] steer_core::error::Error),
51
52    /// Generic errors
53    #[error("{0}")]
54    Generic(String),
55
56    /// Configuration errors
57    #[error("Configuration error: {0}")]
58    Config(String),
59
60    /// Authentication errors
61    #[error("Authentication error: {0}")]
62    Auth(String),
63
64    /// gRPC errors from steer-grpc
65    #[error("gRPC error: {0}")]
66    Grpc(#[from] Box<steer_grpc::GrpcError>),
67
68    /// TUI command parsing errors
69    #[error("TUI command parsing error: {0}")]
70    TuiCommandParsing(#[from] crate::tui::commands::TuiCommandError),
71}
72
73// Convert notify-rust errors to our error type
74impl From<notify_rust::error::Error> for Error {
75    fn from(err: notify_rust::error::Error) -> Self {
76        Error::Notification(err.to_string())
77    }
78}
79
80impl From<steer_grpc::GrpcError> for Error {
81    fn from(err: steer_grpc::GrpcError) -> Self {
82        Error::Grpc(Box::new(err))
83    }
84}