Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |
Sometimes you want to create a handler that catches any
type of exception. You do this using the ellipsis in the argument list:
catch(...) {
cout << "an exception was thrown"
<< endl;
}
Because an ellipsis catches any exception, you ll want to
put it at the end of your list of handlers to avoid pre-empting any that
follow it.
The ellipsis gives you no possibility to have an argument, so
you can t know anything about the exception or its type. It s a catchall.
Such a catch clause is often used to clean up some resources and then
rethrow the exception.
Thinking in C++ Vol 2 - Practical Programming |
Prev |
Home |
Next |