difftreelog
feat(evaluator) anyhow integration
in: master
3 files changed
Cargo.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",
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth17faster = []17faster = []18# Rustc-like trace visualization18# Rustc-like trace visualization19explaining-traces = ["annotate-snippets"]19explaining-traces = ["annotate-snippets"]20# Allows library authors to throw custom errors21anyhow-error = ["anyhow"]202221# Unlocks extra features, but works only on unstable23# Unlocks extra features, but works only on unstable22unstable = []24unstable = []373938thiserror = "1.0"40thiserror = "1.0"394140# Serialized stdlib42[dependencies.anyhow]43version = "1.0"44optional = true4546# Serialized stdlib41[dependencies.serde]47[dependencies.serde]42version = "1.0"48version = "1.0"43optional = true49optional = truecrates/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)