Here's the pseudocode with multiple catch blocks: In C++, include for the exception types.
Catch by reference to avoid slicing.
The order matters: specific catches first, general fallback last. You write catch (invalid_argument& e) before catch (runtime_error& e) because invalid_argument derives from runtime_error.