diff options
author | Nadrieril | 2019-05-06 22:09:55 +0200 |
---|---|---|
committer | Nadrieril | 2019-05-06 22:09:55 +0200 |
commit | 423fdeebe9247b16744fae4b50df415bbd08be04 (patch) | |
tree | f2f16407d7e365e6fecee400a1959ca08b2a5156 /dhall/src/error | |
parent | 2075cba6d883278a534afd2d8fe8f0a5e9b2f0d0 (diff) |
Reorganize dhall into a phase structure
Diffstat (limited to '')
-rw-r--r-- | dhall/src/error.rs | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/dhall/src/error.rs b/dhall/src/error.rs index 6ed0bfb..8497a91 100644 --- a/dhall/src/error.rs +++ b/dhall/src/error.rs @@ -1,13 +1,21 @@ +use std::io::Error as IOError; + +use dhall_syntax::ParseError; + +use crate::phase::binary::DecodeError; +use crate::phase::resolve::ImportError; +use crate::phase::typecheck::TypeError; + pub type Result<T> = std::result::Result<T, Error>; #[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), + IO(IOError), + Parse(ParseError), + Decode(DecodeError), + Resolve(ImportError), + Typecheck(TypeError), Deserialize(String), } @@ -25,28 +33,28 @@ impl std::fmt::Display for Error { } impl std::error::Error for Error {} -impl From<std::io::Error> for Error { - fn from(err: std::io::Error) -> Error { +impl From<IOError> for Error { + fn from(err: IOError) -> Error { Error::IO(err) } } -impl From<dhall_syntax::ParseError> for Error { - fn from(err: dhall_syntax::ParseError) -> Error { +impl From<ParseError> for Error { + fn from(err: ParseError) -> Error { Error::Parse(err) } } -impl From<crate::binary::DecodeError> for Error { - fn from(err: crate::binary::DecodeError) -> Error { +impl From<DecodeError> for Error { + fn from(err: DecodeError) -> Error { Error::Decode(err) } } -impl From<crate::imports::ImportError> for Error { - fn from(err: crate::imports::ImportError) -> Error { +impl From<ImportError> for Error { + fn from(err: ImportError) -> Error { Error::Resolve(err) } } -impl From<crate::typecheck::TypeError> for Error { - fn from(err: crate::typecheck::TypeError) -> Error { +impl From<TypeError> for Error { + fn from(err: TypeError) -> Error { Error::Typecheck(err) } } |