git.delta.rocks / jrsonnet / refs/commits / 3b19e49816fb

difftreelog

feat(evaluator) anyhow integration

Yaroslav Bolyukin2021-01-28parent: #f91abe0.patch.diff
in: master

3 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -11,6 +11,12 @@
 ]
 
 [[package]]
+name = "anyhow"
+version = "1.0.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
+
+[[package]]
 name = "atty"
 version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -163,6 +169,7 @@
 version = "0.3.4"
 dependencies = [
  "annotate-snippets",
+ "anyhow",
  "base64",
  "bincode",
  "closure",
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -17,6 +17,8 @@
 faster = []
 # Rustc-like trace visualization
 explaining-traces = ["annotate-snippets"]
+# Allows library authors to throw custom errors
+anyhow-error = ["anyhow"]
 
 # Unlocks extra features, but works only on unstable
 unstable = []
@@ -37,6 +39,10 @@
 
 thiserror = "1.0"
 
+[dependencies.anyhow]
+version = "1.0"
+optional = true
+
 # Serialized stdlib
 [dependencies.serde]
 version = "1.0"
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
124 #[error("sort error: {0}")]124 #[error("sort error: {0}")]
125 Sort(#[from] SortError),125 Sort(#[from] SortError),
126
127 #[cfg(feature = "anyhow-error")]
128 #[error(transparent)]
129 Other(Rc<anyhow::Error>)
126}130}
131
132#[cfg(feature = "anyhow-error")]
133impl From<anyhow::Error> for LocError {
134 fn from(e: anyhow::Error) -> Self {
135 Self::new(Error::Other(Rc::new(e)))
136 }
137}
138
127impl From<Error> for LocError {139impl From<Error> for LocError {
128 fn from(e: Error) -> Self {140 fn from(e: Error) -> Self {