dstar_gateway/tokio_shell/
error.rs

1//! Shell-level error type wrapping the sans-io core error + adding
2//! tokio-specific failure modes (channel closed, disconnect timeout).
3
4use dstar_gateway_core::error::Error as CoreError;
5
6/// Errors raised by the tokio shell.
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum ShellError {
10    /// Underlying core error (I/O, protocol, type validation, timeout).
11    #[error(transparent)]
12    Core(#[from] CoreError),
13
14    /// The session task has stopped — handle is no longer valid.
15    #[error("session task closed")]
16    SessionClosed,
17
18    /// Disconnect did not complete within the timeout.
19    #[error("disconnect timed out")]
20    DisconnectTimeout,
21}
22
23#[cfg(test)]
24mod tests {
25    use super::*;
26
27    #[test]
28    fn shell_error_session_closed_display() {
29        let err = ShellError::SessionClosed;
30        assert_eq!(err.to_string(), "session task closed");
31    }
32
33    #[test]
34    fn shell_error_disconnect_timeout_display() {
35        let err = ShellError::DisconnectTimeout;
36        assert_eq!(err.to_string(), "disconnect timed out");
37    }
38}