set_unexpected() — Register a function for unexpected()
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ANSI/ISO |
C++ only |
Format
#include <exception>
unexpected_handler set_unexpected(unexpected_handler ph) throw();
General description
The set_unexpected() function is part of the z/OS® XL C++ error handling mechanism. The argument supplied to set_unexpected() is of type unexpected_handler as defined in the header <exception> (that is, a pointer to a function with a void return type and no arguments). The function specified will be called by the unexpected() function.
Note
that the function registered for unexpected() must not return to its
caller. It may terminate execution by:
- Throwing an object of a type listed in the exception specification (or an object of any type if the unexpected handler is called directly by the program).
- Throwing an object of type bad_exception.
- Calling terminate(), abort(), or exit(int).
In a multithreaded environment, the unexpected() function created by the issuance of a set_unexpected() call applies to all threads in the (POSIX) process.
Returned value
set_unexpected() returns the address of the previous unexpected_handler.
Refer to z/OS XL C/C++ Language Reference for more information about z/OS XL C++ exception handling, including the set_unexpected() function.