aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-18 22:48:02 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-18 22:48:02 +0000
commitb12733d16f6896790c3763fbdd47c4c3619da927 (patch)
tree5e1193712cd8f2e6fef32bdc38f5d7abcca982a3
parent4fd61d1e8a673a714048f9c674e5ca75ef45e6c0 (diff)
downloadpaludis-b12733d16f6896790c3763fbdd47c4c3619da927.tar.gz
paludis-b12733d16f6896790c3763fbdd47c4c3619da927.tar.xz
Better error messages
-rw-r--r--paludis/version_spec.cc34
1 files changed, 21 insertions, 13 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 2ed2e76..56c0238 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -136,24 +136,32 @@ VersionSpec::VersionSpec(const std::string & text) :
if (number_part.empty())
throw BadVersionSpecError(text, "Expected number part not found at offset " + stringify(p));
- if (first)
- _imp->parts.push_back(Part(number, destringify<unsigned long, BadVersionSpecError>(number_part), 0));
- else
+ try
{
- if ('0' == number_part.at(0))
+ if (first)
+ _imp->parts.push_back(Part(number, destringify<unsigned long, BadVersionSpecError>(number_part), 0));
+ else
{
- q = number_part.find_first_not_of("0");
- if (std::string::npos == q)
- _imp->parts.push_back(Part(number, 0, 0));
+ if ('0' == number_part.at(0))
+ {
+ q = number_part.find_first_not_of("0");
+ if (std::string::npos == q)
+ _imp->parts.push_back(Part(number, 0, 0));
+ else
+ _imp->parts.push_back(Part(number, destringify<unsigned long, BadVersionSpecError>(
+ strip_trailing(number_part, "0")), q));
+ }
else
- _imp->parts.push_back(Part(number, destringify<unsigned long, BadVersionSpecError>(strip_trailing(number_part, "0")), q));
+ _imp->parts.push_back(Part(number, destringify<unsigned long, BadVersionSpecError>(number_part), 0));
}
- else
- _imp->parts.push_back(Part(number, destringify<unsigned long, BadVersionSpecError>(number_part), 0));
- }
- if (p < text.length() && '.' != text.at(p))
- break;
+ if (p < text.length() && '.' != text.at(p))
+ break;
+ }
+ catch (const BadVersionSpecError &)
+ {
+ throw BadVersionSpecError(text, "Number part '" + number_part + "' contains more than the permitted eight digits");
+ }
++p;
first = false;