summaryrefslogtreecommitdiff
path: root/src/option.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-31 03:34:32 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-31 04:07:33 -0400
commit4427016b1bc20fac4c1700e4f1577f6c7f9ab78c (patch)
tree26ad49d11ee95667aea74e3513b168c864a569c0 /src/option.h
parent77c9d7b1ff9fc0033e653453e08d042b2e95692b (diff)
downloadfork-ledger-4427016b1bc20fac4c1700e4f1577f6c7f9ab78c.tar.gz
fork-ledger-4427016b1bc20fac4c1700e4f1577f6c7f9ab78c.tar.bz2
fork-ledger-4427016b1bc20fac4c1700e4f1577f6c7f9ab78c.zip
Improved arg checking for several valexpr functions
Diffstat (limited to 'src/option.h')
-rw-r--r--src/option.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/option.h b/src/option.h
index 83710a1c..0600779c 100644
--- a/src/option.h
+++ b/src/option.h
@@ -162,10 +162,21 @@ public:
virtual void handler(call_scope_t& args) {
if (wants_arg) {
- if (args.empty() || args.size() == 1)
+ if (args.size() < 2)
throw_(std::runtime_error, _("No argument provided for %1") << desc());
+ else if (args.size() > 2)
+ throw_(std::runtime_error, _("To many arguments provided for %1") << desc());
+ else if (! args[0].is_string())
+ throw_(std::runtime_error, _("Context argument for %1 not a string") << desc());
on_with(args[0].as_string(), args[1]);
- } else {
+ }
+ else if (args.size() < 1) {
+ throw_(std::runtime_error, _("No argument provided for %1") << desc());
+ }
+ else if (! args[0].is_string()) {
+ throw_(std::runtime_error, _("Context argument for %1 not a string") << desc());
+ }
+ else {
on_only(args[0].as_string());
}