473,804 Members | 3,903 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_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

Thanks
Ross
Jul 23 '05 #1
3 4521
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.publi c.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_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
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_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

Thanks
Ross

It's OT, but look here.

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/vclang/html/_core_exception _handling_diffe rences.asp>
Jul 23 '05 #4

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

Similar topics

11
2888
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 return code (not generating error/exception) so it is more compatible with other programming language.
6
2344
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 assemblies are loaded before shutting down. In one case, some of my DB-accessing code didn't handle a NULL value properly. But try...catch wouldn't catch the exception and keep going. I'd just get the error message and then it would shut the...
7
6009
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
2754
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 exception handling mechanism which will allow me to pass character information about an error and its location from lower-level classes. Can you please critique the following exception handling mechanism in terms of my requirements ?
2
2597
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 Layer. My questions is where should I put exception handling: 1) Should it be put in all significant methods in all layers? 2) Should I create an exception base class that will handle the errors and pass useful error messages to the user?
9
2541
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 the way of CPU usage), compared to the "normal" practise returning values. How true is this? Will using using exception handling, in general, be much less efficient than returning values, or less efficient at all? Just curious...
44
4235
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 user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
4
5139
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 .NET 2003\Vc7\include\xstring(1453) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
41
3084
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 handle all of them. I don't care about which one happened, except to write out exception.Message to a log file. It seems verbose to write out three handlers that all do the same thing. So, I could just catch Exception. But, is that...
1
3113
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
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10329
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7626
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.