Skip to main content

zeph_tui/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4/// Errors produced by the TUI subsystem.
5///
6/// All variants implement [`std::error::Error`] via [`thiserror`] and carry a
7/// source error for full cause chains.
8///
9/// # Examples
10///
11/// ```rust
12/// use zeph_tui::TuiError;
13///
14/// fn check(e: &TuiError) -> bool {
15///     matches!(e, TuiError::Io(_))
16/// }
17///
18/// let io_err = std::io::Error::other("disk full");
19/// let tui_err = TuiError::from(io_err);
20/// assert!(check(&tui_err));
21/// ```
22#[derive(Debug, thiserror::Error)]
23pub enum TuiError {
24    /// A terminal I/O operation failed (e.g. enabling raw mode or drawing).
25    #[error("terminal I/O error: {0}")]
26    Io(#[from] std::io::Error),
27    /// The agent channel reported an error (e.g. the channel was closed unexpectedly).
28    #[error("channel error: {0}")]
29    Channel(#[from] zeph_core::channel::ChannelError),
30}