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
17faster = []17faster = []
18# Rustc-like trace visualization18# Rustc-like trace visualization
19explaining-traces = ["annotate-snippets"]19explaining-traces = ["annotate-snippets"]
20# Allows library authors to throw custom errors
21anyhow-error = ["anyhow"]
2022
21# Unlocks extra features, but works only on unstable23# Unlocks extra features, but works only on unstable
22unstable = []24unstable = []
3739
38thiserror = "1.0"40thiserror = "1.0"
3941
40# Serialized stdlib42[dependencies.anyhow]
43version = "1.0"
44optional = true
45
46# Serialized stdlib
41[dependencies.serde]47[dependencies.serde]
42version = "1.0"48version = "1.0"
43optional = true49optional = true
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -123,7 +123,19 @@
 	TypeError(TypeLocError),
 	#[error("sort error: {0}")]
 	Sort(#[from] SortError),
+	
+	#[cfg(feature = "anyhow-error")]
+	#[error(transparent)]
+	Other(Rc<anyhow::Error>)
+}
+
+#[cfg(feature = "anyhow-error")]
+impl From<anyhow::Error> for LocError {
+	fn from(e: anyhow::Error) -> Self {
+		Self::new(Error::Other(Rc::new(e)))
+	}
 }
+
 impl From<Error> for LocError {
 	fn from(e: Error) -> Self {
 		Self::new(e)