Checkpoint: Config parser with a field-aware exception
Challenge on lesson: Checkpoint: A Parser That Explains Itself
CHALLENGE
Difficulty: intermediate+25 XP
Implement int parse_config_value(const std::string& content) scanning lines for one starting with value=. Return the parsed non-negative number. Throw a custom ConfigError (deriving from std::runtime_error, carrying the offending line number as a field, exposed via line_no()) when the value is missing, empty, or non-numeric โ the exception's what() must read line <N>: <message> with the REAL line number (1-based).
Press Submit to check your solution.
Back to lesson: Checkpoint: A Parser That Explains Itself