Ross wrote:
Hi,
I have a message box that displays the message "Unhandled exception in
Cash32.exe: 0xC000005: access violation".
Is there anyway to write an exception that handles this message. For
example
class microsoft_error s{};
some_function()
{
try{
// some code
if (exception = OxC0000005){
throw microsoft_error s();
else
//Continue as normal;
}
catch(microsoft _errors){
message box ("error found in some_function() in XXX.cpp line X ")
}
}//end function
You may use catch(...) to catch the rest of the exceptions that you do
not catch with the catch() expressions you already have.
All ISO C++ standard library exceptions are derived from std::exception
defined in <exception>. So for ISO C++ standard library ones you may do:
catch(std::exce ption &e)
{
// perhaps use e.what().
//
// E.g.
// using namespace System;
//
// MessageBox::Sho w(__gc new String(e.what() ), "Uncaught Exception",
// MessageBoxButto ns::OK, MessageBoxIcon: :Error);
}
In .NET, all .NET managed exceptions are derived from Exception, you can
use catch(Exception *pe) to catch all .NET managed exceptions.
For example you may do:
catch(System::E xception *pe)
{
using namespace System;
MessageBox::Sho w(pe->Message, "Uncaught Exception",
MessageBoxButto ns::OK, MessageBoxIcon: :Error);
Application::Ex it();
}
BTW this is off topic in clc++ and you should ask in
microsoft.publi c.dotnet.langua ges.vc.
If it doesn't appear in your news server use the public MS news server:
msnews.microsof t.com
--
Ioannis Vranos
http://www23.brinkster.com/noicys