Better handling of number parsing exceptions.
This commit is contained in:
parent
d7984e9b3a
commit
6d7954e661
@ -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");
|
||||||
|
Reference in New Issue
Block a user