master
Avril 4 years ago
parent f3c0737c8e
commit 8fdd1a6353
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -7,6 +7,7 @@ use std::{
#[derive(Debug)]
pub enum Error {
IO(io::Error),
Syntax(sexp::Error),
Unknown,
}
@ -17,6 +18,7 @@ impl std::error::Error for Error
{
Some(match &self {
Self::IO(io) => io,
Self::Syntax(sy) => sy,
_ => return None,
})
}
@ -27,7 +29,9 @@ impl std::fmt::Display for Error
{
match self {
Self::IO(io) => write!(f, "i/o error: {}", io),
Self::Unknown => write!(f, "unknown error")
Self::Syntax(sy) => write!(f, "s-expression syntax error: {}", sy),
_ => write!(f, "unknown error")
}
}
}
@ -40,3 +44,18 @@ impl From<io::Error> for Error
}
}
impl From<sexp::Error> for Error
{
fn from(from: sexp::Error) -> Self
{
Self::Syntax(from)
}
}
impl From<Box<sexp::Error>> for Error
{
fn from(from: Box<sexp::Error>) -> Self
{
Self::Syntax(*from)
}
}

Loading…
Cancel
Save