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_errors{};
some_function()
{
try{
// some code
if (exception = OxC0000005){
throw microsoft_errors();
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::exception &e)
{
// perhaps use e.what().
//
// E.g.
// using namespace System;
//
// MessageBox::Show(__gc new String(e.what()), "Uncaught Exception",
// MessageBoxButtons::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::Exception *pe)
{
using namespace System;
MessageBox::Show(pe->Message, "Uncaught Exception",
MessageBoxButtons::OK, MessageBoxIcon::Error);
Application::Exit();
}
BTW this is off topic in clc++ and you should ask in
microsoft.public.dotnet.languages.vc.
If it doesn't appear in your news server use the public MS news server:
msnews.microsoft.com
--
Ioannis Vranos
http://www23.brinkster.com/noicys