Skip to main content

Practice · 1 of 1

Throw the right exception type

CHALLENGE
Difficulty: intermediate+25 XP

Implement int validate_line(const std::string& line) interpreting the line as a non-negative integer: throw std::invalid_argument for an empty line, a leading '-', or any non-digit; throw std::out_of_range when the parsed value exceeds 100; otherwise return the value.

Back to lesson: Practice: Exception practice