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

difftreelog

feat enable friendly-errors by default

Yaroslav Bolyukin2023-06-14parent: #bbe146e.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
8edition = "2021"8edition = "2021"
99
10[features]10[features]
11default = ["explaining-traces", "friendly-errors"]11default = ["explaining-traces"]
12# Rustc-like trace visualization12# Rustc-like trace visualization
13explaining-traces = ["annotate-snippets"]13explaining-traces = ["annotate-snippets"]
14# Allows library authors to throw custom errors14# Allows library authors to throw custom errors
15anyhow-error = ["anyhow"]15anyhow-error = ["anyhow"]
16# Provides helpful explaintations to errors, at cost of adding
17# more dependencies and slowing down error path
18friendly-errors = ["strsim"]
19# Adds ability to build import closure in async16# Adds ability to build import closure in async
20async-import = ["async-trait"]17async-import = ["async-trait"]
2118
45rustc-hash = "1.1"42rustc-hash = "1.1"
4643
47thiserror = "1.0"44thiserror = "1.0"
45# Friendly errors
46strsim = { version = "0.10.0" }
4847
49serde = "1.0"48serde = "1.0"
5049
51anyhow = { version = "1.0", optional = true }50anyhow = { version = "1.0", optional = true }
52# Friendly errors
53strsim = { version = "0.10.0", optional = true }
54# Serialized stdlib51# Serialized stdlib
55bincode = { version = "1.3", optional = true }52bincode = { version = "1.3", optional = true }
56# Explaining traces53# Explaining traces
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
51 self.0.sup.as_ref()51 self.0.sup.as_ref()
52 }52 }
5353
54 #[cfg(not(feature = "friendly-errors"))]
55 pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {
56 Ok(self
57 .0
58 .bindings
59 .get(&name)
60 .cloned()
61 .ok_or(VariableIsNotDefined(name, vec![]))?)
62 }
63
64 #[cfg(feature = "friendly-errors")]
65 pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {54 pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {
66 use std::cmp::Ordering;55 use std::cmp::Ordering;
6756
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
1use std::{1use std::{
2 cmp::Ordering,
2 fmt::{Debug, Display},3 fmt::{Debug, Display},
3 path::PathBuf, cmp::Ordering,4 path::PathBuf,
4};5};
56
6use jrsonnet_gcmodule::Trace;7use jrsonnet_gcmodule::Trace;
79 if conf < 0.8 {80 if conf < 0.8 {
80 continue;81 continue;
81 }82 }
82 if field.as_str() == key.as_str() {83 assert!(field.as_str() != key.as_str(), "looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");
83 panic!("looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");84
84 }
85 heap.push((conf, field));85 heap.push((conf, field));
86 }86 }
87 heap.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(Ordering::Equal));87 heap.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(Ordering::Equal));
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
1use std::{cmp::Ordering, rc::Rc};1use std::rc::Rc;
22
3use jrsonnet_gcmodule::{Cc, Trace};3use jrsonnet_gcmodule::{Cc, Trace};
4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
12use crate::{12use crate::{
13 arr::ArrValue,13 arr::ArrValue,
14 destructure::evaluate_dest,14 destructure::evaluate_dest,
15 error::{ErrorKind::*, suggest_object_fields},15 error::{suggest_object_fields, ErrorKind::*},
16 evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},16 evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
17 function::{CallLocation, FuncDesc, FuncVal},17 function::{CallLocation, FuncDesc, FuncVal},
18 throw,18 throw,