From 0afc5f71ec0d4159f9d6ad052dcfc7950fa62d0f Mon Sep 17 00:00:00 2001 From: Лач Date: Sat, 27 Jun 2020 12:29:24 +0000 Subject: [PATCH] fix(evaluator): use exceptions instead of panic in functions --- --- a/crates/jsonnet-evaluator/src/evaluate.rs +++ b/crates/jsonnet-evaluator/src/evaluate.rs @@ -718,7 +718,10 @@ Val::Str(manifest_json_ex(&value, &indent)?.into()) }) } - (ns, name) => panic!("Intristic not found: {}.{}", ns, name), + (ns, name) => create_error(crate::error::Error::IntristicNotFound( + ns.into(), + name.into(), + ))?, }, Val::Func(f) => { let body = || f.evaluate(context, args, *tailstrict); @@ -728,7 +731,9 @@ push(loc, "function call", body)? } } - _ => panic!("{:?} is not a function", value), + v => create_error(crate::error::Error::OnlyFunctionsCanBeCalledGot( + v.value_type()?, + ))?, } } Function(params, body) => evaluate_method(context, params.clone(), body.clone()), -- gitstuff