set_unexpected (
This page is specific to:.NET Framework Version:
1.12.03.54
Standard C++ Library Reference 
set_unexpected (<exception>) 

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

unexpected_handler
   set_unexpected(
      unexpected_handler _Pnew
   ) throw( );

Parameters

_Pnew

The function to be called at

Return Value

The address of the previous unexpected_handler.

Remarks

_Pnew 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.

Example

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

using namespace std;

void unfunction( ) 
{
   cout << "I'll be back." << endl;
   terminate( );
}

int main( ) 
{
   unexpected_handler oldHand = set_unexpected( unfunction );
   unexpected( );
}

Output

I'll be back.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Requirements

Header: <exception>

See Also

Other Resources

<exception> Members

© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View