Log It, Then Rethrow
Log It, Then Rethrow
The function loadLevel(int number) is already written: it returns the points for a level, or throws a std::runtime_error when the level is above 3. Write loadWithLog(int number), which returns whatever loadLevel returns. When loadLevel throws, catch the std::runtime_error, print log: followed by its message, and then rethrow the very same exception with a bare throw; so the caller still gets it. A bare throw inside a handler rethrows the exception being handled; writing throw e; would throw a copy instead.
The tests call loadWithLog for a few levels inside their own try/catch, printing points: and the value, or main caught: and the message after your log line.
Do NOT write a main function.
Expected Output:
points: 200 log: Level 5 is locked main caught: Level 5 is locked
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...