summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src')
-rw-r--r--dhall/src/error.rs73
-rw-r--r--dhall/src/imports.rs11
2 files changed, 50 insertions, 34 deletions
diff --git a/dhall/src/error.rs b/dhall/src/error.rs
index cfd6f09..0a02816 100644
--- a/dhall/src/error.rs
+++ b/dhall/src/error.rs
@@ -1,32 +1,51 @@
-use quick_error::quick_error;
-
pub type Result<T> = std::result::Result<T, Error>;
-quick_error! {
- #[derive(Debug)]
- pub enum Error {
- IO(err: std::io::Error) {
- from()
- display("{}", err)
- }
- Parse(err: dhall_core::ParseError) {
- from()
- display("{}", err)
- }
- Decode(err: crate::binary::DecodeError) {
- from()
- display("{:?}", err)
- }
- Resolve(err: crate::imports::ImportError) {
- from()
- display("{}", err)
- }
- Typecheck(err: crate::typecheck::TypeError<dhall_core::X>) {
- from()
- display("{:?}", err)
- }
- Deserialize(err: String) {
- display("{}", err)
+#[derive(Debug)]
+pub enum Error {
+ IO(std::io::Error),
+ Parse(dhall_core::ParseError),
+ Decode(crate::binary::DecodeError),
+ Resolve(crate::imports::ImportError),
+ Typecheck(crate::typecheck::TypeError<dhall_core::X>),
+ 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<std::io::Error> for Error {
+ fn from(err: std::io::Error) -> Error {
+ Error::IO(err)
+ }
+}
+impl From<dhall_core::ParseError> for Error {
+ fn from(err: dhall_core::ParseError) -> Error {
+ Error::Parse(err)
+ }
+}
+impl From<crate::binary::DecodeError> for Error {
+ fn from(err: crate::binary::DecodeError) -> Error {
+ Error::Decode(err)
+ }
+}
+impl From<crate::imports::ImportError> for Error {
+ fn from(err: crate::imports::ImportError) -> Error {
+ Error::Resolve(err)
+ }
+}
+impl From<crate::typecheck::TypeError<dhall_core::X>> for Error {
+ fn from(err: crate::typecheck::TypeError<dhall_core::X>) -> Error {
+ Error::Typecheck(err)
+ }
+}
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index 7810c55..e42bfec 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -1,18 +1,15 @@
use crate::error::Error;
use crate::expr::*;
use dhall_core::*;
-use quick_error::quick_error;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::path::PathBuf;
-quick_error! {
- #[derive(Debug)]
- pub enum ImportError {
- Recursive(import: Import, err: Box<Error>) {}
- UnexpectedImport(import: Import) {}
- }
+#[derive(Debug)]
+pub enum ImportError {
+ Recursive(Import, Box<Error>),
+ UnexpectedImport(Import),
}
/// A root from which to resolve relative imports.