The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

set_unexpected (<exception>)

Establishes a new unexpected_handler to be when an unexpected exception is encountered.

      unexpected_handler fnew 
   ) throw( );


The function to be called when an unexpected exception is encountered.

The address of the previous unexpected_handler.

fnew must not be a null pointer.

The C++ Standard requires that unexpected is called when a function throws an exception that is not on its throw list. The current implementation does not support this. The following example calls unexpected directly, which then calls the unexpected_handler.

// exception_set_unexpected.cpp
// compile with: /EHsc
#include <exception>
#include <iostream>

using namespace std;

void uefunction()
    cout << "My unhandled exception function called." << endl;
    terminate(); // this is what unexpected() calls by default

int main()
    unexpected_handler oldHandler = set_unexpected(uefunction);

    unexpected(); // library function to force calling the 
                  // current unexpected handler

My unhandled exception function called.

Header: <exception>

Namespace: std

© 2014 Microsoft