| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Ross" |
| Date: |
28 Feb 2005 11:21:40 AM |
| Object: |
Exception Handling |
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
.
|
|
| User: "red floyd" |
|
| Title: Re: Exception Handling |
28 Feb 2005 09:47:54 PM |
|
|
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
Thanks
Ross
It's OT, but look here.
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_core_exception_handling_differences.asp>
.
|
|
|
|
| User: "Ioannis Vranos" |
|
| Title: Re: Exception Handling |
28 Feb 2005 12:06:03 PM |
|
|
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
.
|
|
|
|
| User: "Victor Bazarov" |
|
| Title: Re: Exception Handling |
28 Feb 2005 11:29:00 AM |
|
|
Ross wrote:
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.
.
|
|
|
|

|
Related Articles |
|
|