aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-29 12:07:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-29 12:07:50 +0000
commita17a68c762433ba16c0e722f9cc9b130f015d596 (patch)
tree040a7f68faad1bdd221864550b89e7dbb8e25cec
parent5bfb8244277aa909a26141ddae05888d013191be (diff)
downloadpaludis-a17a68c762433ba16c0e722f9cc9b130f015d596.tar.gz
paludis-a17a68c762433ba16c0e722f9cc9b130f015d596.tar.xz
Extend exception messages for bad version specs
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc5
-rw-r--r--paludis/util/exception.cc5
-rw-r--r--paludis/util/exception.hh10
-rw-r--r--paludis/version_spec.cc11
-rw-r--r--paludis/version_spec.hh7
5 files changed, 29 insertions, 9 deletions
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index a8b50bb..496d45e 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -580,11 +580,12 @@ PortageRepository::need_version_names(const QualifiedPackageName & n) const
strip_trailing_string(e->basename(), _imp->entries_ptr->file_extension()),
stringify(n.package) + "-")));
}
- catch (const NameError &)
+ catch (const NameError & ee)
{
Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '"
+ stringify(*e) + "' for '" + stringify(n) + "' in repository '"
- + stringify(name()) + "'");
+ + stringify(name()) + "' due to exception '" + ee.message() + "' ("
+ + ee.what() + ")'");
}
}
diff --git a/paludis/util/exception.cc b/paludis/util/exception.cc
index 055e151..2976fdf 100644
--- a/paludis/util/exception.cc
+++ b/paludis/util/exception.cc
@@ -119,6 +119,11 @@ NameError::NameError(const std::string & name, const std::string & role) throw (
{
}
+NameError::NameError(const std::string & name, const std::string & role, const std::string & msg) throw () :
+ Exception("Name '" + name + "' is not a valid " + role + ": " + msg)
+{
+}
+
ConfigurationError::ConfigurationError(const std::string & msg) throw () :
Exception(msg)
{
diff --git a/paludis/util/exception.hh b/paludis/util/exception.hh
index a7504f1..4671c34 100644
--- a/paludis/util/exception.hh
+++ b/paludis/util/exception.hh
@@ -191,6 +191,16 @@ namespace paludis
* \param role The role for the name, for example "package name".
*/
NameError(const std::string & name, const std::string & role) throw ();
+
+ /**
+ * Constructor.
+ *
+ * \param name The invalid name encountered.
+ * \param role The role for the name, for example "package name".
+ * \param msg Any extra message.
+ */
+ NameError(const std::string & name, const std::string & role,
+ const std::string & msg) throw ();
};
/**
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 9919e1b..5d24280 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -39,6 +39,11 @@ BadVersionSpecError::BadVersionSpecError(const std::string & name) throw () :
{
}
+BadVersionSpecError::BadVersionSpecError(const std::string & name, const std::string & msg) throw () :
+ NameError(name, "version spec", msg)
+{
+}
+
namespace
{
/**
@@ -103,7 +108,7 @@ VersionSpec::VersionSpec(const std::string & text) :
Context c("When parsing version spec '" + text + "':");
if (text.empty())
- throw BadVersionSpecError(text);
+ throw BadVersionSpecError(text, "cannot be empty");
/* set us up with some sane defaults */
_imp->text = text;
@@ -123,7 +128,7 @@ VersionSpec::VersionSpec(const std::string & text) :
while (p < text.length())
{
if (text.at(p) < '0' || text.at(p) > '9')
- throw BadVersionSpecError(text);
+ throw BadVersionSpecError(text, "expected a digit but found '" + stringify(text.at(p)) + "'");
x *= 10;
x += text.at(p) - '0';
@@ -267,7 +272,7 @@ VersionSpec::VersionSpec(const std::string & text) :
/* trailing stuff? */
if (p < text.length())
- throw BadVersionSpecError(text);
+ throw BadVersionSpecError(text, "unexpected trailing text '" + text.substr(p) + "'");
}
VersionSpec::VersionSpec(const VersionSpec & other) :
diff --git a/paludis/version_spec.hh b/paludis/version_spec.hh
index 82599b2..01c1450 100644
--- a/paludis/version_spec.hh
+++ b/paludis/version_spec.hh
@@ -42,13 +42,12 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grpversions
*/
- class BadVersionSpecError : public NameError
+ class BadVersionSpecError :
+ public NameError
{
public:
- /**
- * Constructor.
- */
BadVersionSpecError(const std::string & name) throw ();
+ BadVersionSpecError(const std::string & name, const std::string & msg) throw ();
};
/**