git.delta.rocks / jrsonnet / refs/commits / 0afc5f71ec0d

difftreelog

fix(evaluator) use exceptions instead of panic in functions

Лач2020-06-27parent: #bcda254.patch.diff
in: master

1 file changed

modifiedcrates/jsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth
718 Val::Str(manifest_json_ex(&value, &indent)?.into())718 Val::Str(manifest_json_ex(&value, &indent)?.into())
719 })719 })
720 }720 }
721 (ns, name) => panic!("Intristic not found: {}.{}", ns, name),721 (ns, name) => create_error(crate::error::Error::IntristicNotFound(
722 ns.into(),
723 name.into(),
724 ))?,
722 },725 },
723 Val::Func(f) => {726 Val::Func(f) => {
724 let body = || f.evaluate(context, args, *tailstrict);727 let body = || f.evaluate(context, args, *tailstrict);
728 push(loc, "function call", body)?731 push(loc, "function call", body)?
729 }732 }
730 }733 }
731 _ => panic!("{:?} is not a function", value),734 v => create_error(crate::error::Error::OnlyFunctionsCanBeCalledGot(
735 v.value_type()?,
736 ))?,
732 }737 }
733 }738 }
734 Function(params, body) => evaluate_method(context, params.clone(), body.clone()),739 Function(params, body) => evaluate_method(context, params.clone(), body.clone()),