As a natural companion to the try/catch support, the statement module provides lazy throwing and re-throwing of exceptions.
The syntax to throw an exception is:
The syntax to re-throw an exception is:
Example: This code extends the try/catch example, re-throwing exceptions derived from runtime_error or exception, and translating other exception types to runtime_errors.
try_ [ f(arg1) ] .catch_<runtime_error>() [ cout << val("caught runtime error or derived\n"), throw_() ] .catch_<exception>() [ cout << val("caught exception or derived\n"), throw_() ] .catch_all [ cout << val("caught some other type of exception\n"), throw_(runtime_error("translated exception")) ]