aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-15 18:28:59 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-15 18:28:59 +0000
commitf66cbd26c252e4bc149af6de20b9c4f46234cb1e (patch)
treea5299cb027e87f030ad6bfada15b8a02c293473d
parentd80930475d96a59fb30dae346fbd32b9374a0d63 (diff)
downloadpaludis-f66cbd26c252e4bc149af6de20b9c4f46234cb1e.tar.gz
paludis-f66cbd26c252e4bc149af6de20b9c4f46234cb1e.tar.xz
Replace some of the InternalErrors with real exceptions
-rw-r--r--paludis/package_dep_atom.cc13
-rw-r--r--paludis/package_dep_atom.hh7
2 files changed, 16 insertions, 4 deletions
diff --git a/paludis/package_dep_atom.cc b/paludis/package_dep_atom.cc
index 665a917..2c419bb 100644
--- a/paludis/package_dep_atom.cc
+++ b/paludis/package_dep_atom.cc
@@ -60,7 +60,7 @@ PackageDepAtom::PackageDepAtom(const std::string & ss) :
std::string s(ss);
if (s.empty())
- throw InternalError(PALUDIS_HERE, "todo"); /// \bug
+ throw PackageDepAtomError("Got empty dep atom");
std::string::size_type slot_p;
if (std::string::npos != ((slot_p = s.rfind(':'))))
@@ -80,10 +80,10 @@ PackageDepAtom::PackageDepAtom(const std::string & ss) :
while (true)
{
if (p >= s.length())
- throw InternalError(PALUDIS_HERE, "todo"); /// \bug
+ throw PackageDepAtomError("Couldn't parse dep atom '" + ss + "'");
q = s.find('-', q + 1);
if ((std::string::npos == q) || (++q >= s.length()))
- throw InternalError(PALUDIS_HERE, "todo"); /// \bug
+ throw PackageDepAtomError("Couldn't parse dep atom '" + ss + "'");
if (s.at(q) >= '0' && s.at(q) <= '9')
break;
}
@@ -92,7 +92,7 @@ PackageDepAtom::PackageDepAtom(const std::string & ss) :
if ('*' == s.at(s.length() - 1))
{
if (_version_operator != vo_equal)
- throw InternalError(PALUDIS_HERE, "todo"); /// \bug
+ throw PackageDepAtomError("Package dep atom '" + ss + "' uses * but not equals operator");
_version_operator = vo_equal_star;
_version_spec = CountedPtr<VersionSpec, count_policy::ExternalCountTag>(
new VersionSpec(s.substr(q, s.length() - q - 1)));
@@ -145,3 +145,8 @@ paludis::operator<< (std::ostream & s, const PackageDepAtom & a)
return s;
}
+PackageDepAtomError::PackageDepAtomError(const std::string & msg) throw () :
+ Exception(msg)
+{
+}
+
diff --git a/paludis/package_dep_atom.hh b/paludis/package_dep_atom.hh
index 01a8fec..6bbfc50 100644
--- a/paludis/package_dep_atom.hh
+++ b/paludis/package_dep_atom.hh
@@ -113,6 +113,13 @@ namespace paludis
typedef CountedPtr<const PackageDepAtom, count_policy::InternalCountTag> ConstPointer;
};
+ class PackageDepAtomError :
+ public Exception
+ {
+ public:
+ PackageDepAtomError(const std::string & msg) throw ();
+ };
+
/**
* A PackageDepAtom can be written to an ostream.
*/