use std::io;
use crate::client::ClientError;
#[derive(Debug)]
pub enum ViewerError {
Io(io::Error),
Client(ClientError),
ParseFailed,
UnexpectedEffect(&'static str),
TrustDeclined,
InitialNavigationFailed(String),
}
impl std::fmt::Display for ViewerError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ViewerError::Io(e) => write!(f, "{e}"),
ViewerError::Client(e) => write!(f, "{e}"),
ViewerError::ParseFailed => write!(f, "failed to parse AML content"),
ViewerError::TrustDeclined => {
write!(f, "certificate not trusted; nothing was connected to")
}
ViewerError::InitialNavigationFailed(reason) => write!(f, "{reason}"),
ViewerError::UnexpectedEffect(effect) => {
write!(f, "unexpected viewer effect in terminal runtime: {effect}")
}
}
}
}
impl std::error::Error for ViewerError {}
impl From<io::Error> for ViewerError {
fn from(e: io::Error) -> Self {
ViewerError::Io(e)
}
}
impl From<ClientError> for ViewerError {
fn from(e: ClientError) -> Self {
ViewerError::Client(e)
}
}