summaryrefslogtreecommitdiff
path: root/src/op.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-01 22:20:38 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-01 22:20:38 -0600
commitcfd7ffb12645c198a5b15891654f6ad6a0e4db27 (patch)
treec35b041045d078740d5c8f767f81696c2fcc8c27 /src/op.cc
parenta0c9ab08dccf65259474b5da97e4f5b092741779 (diff)
downloadfork-ledger-cfd7ffb12645c198a5b15891654f6ad6a0e4db27.tar.gz
fork-ledger-cfd7ffb12645c198a5b15891654f6ad6a0e4db27.tar.bz2
fork-ledger-cfd7ffb12645c198a5b15891654f6ad6a0e4db27.zip
Provide more context if a valexpr function call fails
Diffstat (limited to 'src/op.cc')
-rw-r--r--src/op.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/op.cc b/src/op.cc
index 372101f0..8e9df812 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -272,10 +272,16 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
if (has_right())
call_args.set_args(split_cons_expr(right()));
- if (func->is_function())
- result = func->as_function()(call_args);
- else
- result = func->calc(call_args, locus, depth + 1);
+ try {
+ if (func->is_function())
+ result = func->as_function()(call_args);
+ else
+ result = func->calc(call_args, locus, depth + 1);
+ }
+ catch (const std::exception&) {
+ add_error_context(_("While calling function '%1':" << name));
+ throw;
+ }
check_type_context(scope, result);
break;
@@ -308,7 +314,8 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
if (args_index < args_count)
throw_(calc_error,
- _("Too few arguments in function call (saw %1)") << args_count);
+ _("Too few arguments in function call (saw %1, wanted %2)")
+ << args_count << args_index);
result = right()->calc(call_scope, locus, depth + 1);
break;