aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Stephen P. Bennett <spb@exherbo.org> 2006-02-19 20:05:02 +0000
committerAvatar Stephen P. Bennett <spb@exherbo.org> 2006-02-19 20:05:02 +0000
commit4c5020c46f1a66b590bbd0846907e14fe9ced3e0 (patch)
tree542d23fc9ac0eca3174e30559b46def24a4f07f9
parent16f7f7f8cbfe93e7ec515c328b750ec2d127d562 (diff)
downloadpaludis-4c5020c46f1a66b590bbd0846907e14fe9ced3e0.tar.gz
paludis-4c5020c46f1a66b590bbd0846907e14fe9ced3e0.tar.xz
Add a MissingValue exception and use it where appropriate.
-rw-r--r--paludis/args/Makefile.am1
-rw-r--r--paludis/args/args_TEST.cc4
-rw-r--r--paludis/args/args_visitor.cc3
-rw-r--r--paludis/args/missing_value.cc36
-rw-r--r--paludis/args/missing_value.hh56
5 files changed, 97 insertions, 3 deletions
diff --git a/paludis/args/Makefile.am b/paludis/args/Makefile.am
index e6c8e75..6dfa2aa 100644
--- a/paludis/args/Makefile.am
+++ b/paludis/args/Makefile.am
@@ -14,6 +14,7 @@ libpaludisargs_a_SOURCES = \
bad_argument.hh bad_argument.cc \
args_visitor.hh args_visitor.cc \
bad_value.hh bad_value.cc \
+ missing_value.hh missing_value.cc \
args_dumper.hh args_dumper.cc
TESTS_ENVIRONMENT = env -u PALUDIS_OPTIONS TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh
diff --git a/paludis/args/args_TEST.cc b/paludis/args/args_TEST.cc
index 79b9783..6da14b9 100644
--- a/paludis/args/args_TEST.cc
+++ b/paludis/args/args_TEST.cc
@@ -18,7 +18,7 @@
*/
#include <paludis/args/args.hh>
-#include <paludis/args/bad_value.hh>
+#include <paludis/args/missing_value.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -117,7 +117,7 @@ namespace test_cases
{
char *args[] = { "program-name", "-e" };
CommandLine c1;
- TEST_CHECK_THROWS(c1.run(2, args), BadValue);
+ TEST_CHECK_THROWS(c1.run(2, args), MissingValue);
}
} test_args_no_param;
}
diff --git a/paludis/args/args_visitor.cc b/paludis/args/args_visitor.cc
index 9cfee95..7a058e6 100644
--- a/paludis/args/args_visitor.cc
+++ b/paludis/args/args_visitor.cc
@@ -19,6 +19,7 @@
#include "args_visitor.hh"
#include "args_option.hh"
#include "bad_value.hh"
+#include "missing_value.hh"
#include <paludis/destringify.hh>
@@ -36,7 +37,7 @@ const std::string& ArgsVisitor::get_param(const ArgsOption * const arg)
{
if (++(*_args_index) == _args_end)
{
- throw BadValue("--" + arg->long_name(), "<none>");
+ throw MissingValue("--" + arg->long_name());
}
return **_args_index;
}
diff --git a/paludis/args/missing_value.cc b/paludis/args/missing_value.cc
new file mode 100644
index 0000000..2474ea5
--- /dev/null
+++ b/paludis/args/missing_value.cc
@@ -0,0 +1,36 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Stephen Bennett <spb@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "missing_value.hh"
+
+/**
+ * \file
+ * Implementation of MissingValue
+ *
+ * \ingroup Args
+ * \ingroup Exception
+ */
+
+using namespace paludis::args;
+
+MissingValue::MissingValue(const std::string & arg) throw() :
+ ArgsError("No parameter given for '" + arg + "'")
+{
+}
diff --git a/paludis/args/missing_value.hh b/paludis/args/missing_value.hh
new file mode 100644
index 0000000..05a0408
--- /dev/null
+++ b/paludis/args/missing_value.hh
@@ -0,0 +1,56 @@
+#ifndef PALUDIS_GUARD_PALUDIS_ARGS_MISSING_VALUE_HH
+#define PALUDIS_GUARD_PALUDIS_ARGS_MISSING_VALUE_HH 1
+
+
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Stephen Bennett <spb@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/args/args_error.hh>
+
+/** \file
+ * Declaration for MissingValue
+ *
+ * \ingroup Args
+ * \ingroup Exception
+ */
+
+namespace paludis
+{
+ namespace args
+ {
+ /**
+ * Thrown if an argument is specified that needs a parameter,
+ * but no parameter is given.
+ *
+ * \ingroup Args
+ * \ingroup Exception
+ */
+ class MissingValue : public ArgsError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ MissingValue(const std::string & arg) throw ();
+ };
+ }
+}
+
+#endif