pub type Result = std::result::Result; #[derive(Debug)] #[non_exhaustive] pub enum Error { IO(std::io::Error), Parse(dhall_syntax::ParseError), Decode(crate::binary::DecodeError), Resolve(crate::imports::ImportError), Typecheck(crate::typecheck::TypeError), Deserialize(String), } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Error::IO(err) => write!(f, "{}", err), Error::Parse(err) => write!(f, "{}", err), Error::Decode(err) => write!(f, "{:?}", err), Error::Resolve(err) => write!(f, "{:?}", err), Error::Typecheck(err) => write!(f, "{:?}", err), Error::Deserialize(err) => write!(f, "{}", err), } } } impl std::error::Error for Error {} impl From for Error { fn from(err: std::io::Error) -> Error { Error::IO(err) } } impl From for Error { fn from(err: dhall_syntax::ParseError) -> Error { Error::Parse(err) } } impl From for Error { fn from(err: crate::binary::DecodeError) -> Error { Error::Decode(err) } } impl From for Error { fn from(err: crate::imports::ImportError) -> Error { Error::Resolve(err) } } impl From for Error { fn from(err: crate::typecheck::TypeError) -> Error { Error::Typecheck(err) } }