Exception Handling

R

Ross

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

Thanks
Ross
 
V

Victor Bazarov

Ross said:
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

Please ask in a Microsoft newsgroup: microsoft.public.vc.language.

IIRC, there is a way, but it's not part of C++, it's part of Windows
API or something like that.
 
I

Ioannis Vranos

Ross said:
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
 
R

red floyd

Ross said:
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

Thanks
Ross


It's OT, but look here.

<http://msdn.microsoft.com/library/d...html/_core_exception_handling_differences.asp>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top