Give a better error when sequences are mis-indexed
This commit is contained in:
parent
080c1d9a2d
commit
02225a014a
1 changed files with 13 additions and 6 deletions
|
|
@ -539,13 +539,20 @@ value_t report_t::fn_get_at(call_scope_t& args)
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
if (! args[0].is_sequence())
|
if (! args[0].is_sequence())
|
||||||
return args[0];
|
return args[0];
|
||||||
} else {
|
}
|
||||||
if (! args[0].is_sequence())
|
else if (! args[0].is_sequence()) {
|
||||||
throw_(std::runtime_error,
|
throw_(std::runtime_error,
|
||||||
_("Attempting to get argument at index %1 from %2")
|
_("Attempting to get argument at index %1 from %2")
|
||||||
<< index << args[0].label());
|
<< index << args[0].label());
|
||||||
}
|
}
|
||||||
return args[0].as_sequence()[index];
|
|
||||||
|
value_t::sequence_t& seq(args[0].as_sequence_lval());
|
||||||
|
if (index >= seq.size())
|
||||||
|
throw_(std::runtime_error,
|
||||||
|
_("Attempting to get index %1 from %2 with %3 elements")
|
||||||
|
<< index << args[0].label() << seq.size());
|
||||||
|
|
||||||
|
return seq[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t report_t::fn_is_seq(call_scope_t& scope)
|
value_t report_t::fn_is_seq(call_scope_t& scope)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue