ailloli_ui_terminal_pty/
error.rs

1//! Serializable failure categories for backend and session operations.
2
3use serde::{Deserialize, Serialize};
4use thiserror::Error;
5
6/// Failure returned by PTY abstraction operations.
7///
8/// Backend error strings are stored verbatim for diagnostics and serialization;
9/// they are not structured sources, redacted, or guaranteed stable across OSes
10/// and backend versions. Match the variant for control flow, not display text.
11///
12/// # Examples
13///
14/// ```
15/// use ailloli_ui_terminal_pty::PtyError;
16/// let error = PtyError::Resize("invalid dimensions".into());
17/// assert_eq!(error.to_string(), "resize failed: invalid dimensions");
18/// assert!(matches!(error, PtyError::Resize(_)));
19/// ```
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Error)]
21pub enum PtyError {
22    /// PTY allocation or child-process spawn failed.
23    #[error("spawn failed: {0}")]
24    Spawn(String),
25    /// Reader creation or another uncategorized PTY I/O operation failed.
26    #[error("I/O failed: {0}")]
27    Io(String),
28    /// Master-side size update or resize locking failed.
29    #[error("resize failed: {0}")]
30    Resize(String),
31    /// Input write, flush, or writer locking failed.
32    #[error("write failed: {0}")]
33    Write(String),
34    /// Child termination or killer locking failed.
35    #[error("shutdown failed: {0}")]
36    Shutdown(String),
37    /// Operation requires a session that has not shut down.
38    #[error("PTY handle is closed")]
39    Closed,
40    /// Selected backend does not implement the requested operation.
41    #[error("unsupported PTY operation: {0}")]
42    Unsupported(String),
43}