Skip to main content

wisp/
error.rs

1use acp_utils::client::AcpClientError;
2use std::fmt;
3
4/// Application-level errors for the Wisp TUI.
5#[derive(Debug)]
6pub enum AppError {
7    Io(std::io::Error),
8    Acp(AcpClientError),
9}
10
11impl fmt::Display for AppError {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match self {
14            Self::Io(e) => write!(f, "I/O error: {e}"),
15            Self::Acp(e) => write!(f, "{e}"),
16        }
17    }
18}
19
20impl std::error::Error for AppError {
21    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
22        match self {
23            Self::Io(e) => Some(e),
24            Self::Acp(e) => Some(e),
25        }
26    }
27}
28
29impl From<std::io::Error> for AppError {
30    fn from(e: std::io::Error) -> Self {
31        Self::Io(e)
32    }
33}
34
35impl From<AcpClientError> for AppError {
36    fn from(e: AcpClientError) -> Self {
37        Self::Acp(e)
38    }
39}