summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock7
-rw-r--r--dhall/Cargo.toml1
-rw-r--r--dhall/src/error.rs73
-rw-r--r--dhall/src/imports.rs11
4 files changed, 50 insertions, 42 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e0a55ca..781c593 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -73,7 +73,6 @@ dependencies = [
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lalrpop-util 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_cbor 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term-painter 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -267,11 +266,6 @@ dependencies = [
]
[[package]]
-name = "quick-error"
-version = "1.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "quote"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -454,7 +448,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f60c0d9f6fc88ecdd245d90c1920ff76a430ab34303fc778d33b1d0a4c3bf6d3"
"checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
-"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4"
diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml
index 7f695d4..0c9b97a 100644
--- a/dhall/Cargo.toml
+++ b/dhall/Cargo.toml
@@ -13,7 +13,6 @@ bytecount = "0.5.1"
itertools = "0.8.0"
lalrpop-util = "0.16.3"
term-painter = "0.2.3"
-quick-error = "1.2.2"
serde = { version = "1.0", features = ["derive"] }
serde_cbor = "0.9.0"
dhall_core = { path = "../dhall_core" }
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.