Better handling of number parsing exceptions.

This commit is contained in:
Patrick Lühne 2016-05-20 16:20:51 +02:00
parent d7984e9b3a
commit 6d7954e661

View File

@ -182,7 +182,15 @@ void Description::parseSectionIdentifier(std::istream &istream, const std::strin
size_t Description::parseNumber(std::istream &istream) const size_t Description::parseNumber(std::istream &istream) const
{ {
auto number = std::numeric_limits<size_t>::max(); auto number = std::numeric_limits<size_t>::max();
try
{
istream >> number; istream >> number;
}
catch (const std::exception &e)
{
throw ParserException("Could not parse number");
}
if (number == std::numeric_limits<size_t>::max()) if (number == std::numeric_limits<size_t>::max())
throw ParserException("Invalid number"); throw ParserException("Invalid number");