473,513 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 23 '05 #1
3 4477
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.
Jul 23 '05 #2
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
Jul 23 '05 #3
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>
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2837
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
6
2322
by: Daniel Wilson | last post by:
I am having exception-handling and stability problems with .NET. I will have a block of managed code inside try...catch and will still get a generic ..NET exception box that will tell me which...
7
5969
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
2736
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
2
2582
by: tom | last post by:
Hi, I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers UI, Business Objects, and Data Access...
9
2523
by: C# Learner | last post by:
Some time ago, I remember reading a discussion about the strengths and weaknesses of exception handling. One of the weaknesses that was put forward was that exception handling is inefficient (in...
44
4162
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
4
5110
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio...
41
3022
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must...
1
3089
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.