473,586 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching unknown exceptions

I have an unknown error in some legacy code. I can catch it with catch
(...), but I cannot tell what kind of error it is.

Is there any base exception class (like in java) that I can try and
catch that might give me some more meaningful information? Or
suggestions on the most common exceptions so I can just try them?

Thanks,
Bryan
Sep 24 '05 #1
3 2112
Ian
Bryan wrote:
I have an unknown error in some legacy code. I can catch it with catch
(...), but I cannot tell what kind of error it is.

Is there any base exception class (like in java) that I can try and
catch that might give me some more meaningful information? Or
suggestions on the most common exceptions so I can just try them?

std::exception

Ian
Sep 24 '05 #2
> std::exception

Not necessarily!

A short answer to OP's question is: "There's no way you can do that".

A slightly longer answer is, if you don't know what exception is being
thrown after consulting all documentation, then it is better to:
- not catching the exception at all, or
- catch it but not to deal with the object being thrown.

Of course, if you are debugging, that's a different story. Your development
tools should have some function to pierce into the exception object
internals.

Ben
Sep 24 '05 #3

Bryan wrote:
I have an unknown error in some legacy code. I can catch it with catch
(...), but I cannot tell what kind of error it is.

Is there any base exception class (like in java) that I can try and
catch that might give me some more meaningful information? Or
suggestions on the most common exceptions so I can just try them?

Thanks,
Bryan


The ellipsis indicates that the catch clause doesn't care what kind of
exception it has caught. Its purpose is to to catch every exception. By
the time this catch clause executes, it's too late to wonder what kind
of exception was thrown. Because if the thrown type really were of
interest, it should have already been caught.

Generally, when the type of a thrown exception can vary, a C++ program
will declare a series of catch clauses with the ellipsis catch-all
coming last:

catch (std::exception & InException)
{
...
}

catch (int inOSErr)
{
...
}

catch (...) // for thrown types not already caught
{
...
}

Greg

Sep 24 '05 #4

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

Similar topics

1
2970
by: Rolf | last post by:
I understand a compilation error occurs when a method that throws no exceptions is the only code in a try block. What I don't understnad is why I can specify the catching of an Exception for a method that throws no exceptions, but I cannot catch an IOException for a method that throws no exceptions? // This try/catch code complies fine,...
2
1762
by: Keith Bolton | last post by:
I am handling exceptions currently using try, except. Generally I don't handle specific exceptions and am catching all. Then if an exception occurs, I would like to capture that error string. However, in the documentation it seems like there is not a way to get the extra str data if you are handling all exceptions and not specifically. Is...
0
2713
by: Steven Reddie | last post by:
In article <slrnbnj19j.av.juergen@monocerus.manannan.org>, Juergen Heinzl wrote: >In article <f93791bd.0309282133.650da850@posting.google.com>, Steven Reddie wrote: >> I understand that access violations aren't part of the standard C++ >> exception handling support. On Windows, a particular MSVC compiler >> option enables Microsoft's...
7
2325
by: cmay | last post by:
FxCop complains every time I catch System.Exception. I don't see the value in trying to catch every possible exception type (or even figuring out what exceptions can be caught) by a given block of code, when System.Exception seems to get the job done for me. My application is an ASP.Net intranet site. When I catch an exception, I log...
12
6097
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls out of which unmanaged exception //get thrown
0
810
by: Wild Wind | last post by:
Hello, I have a mixed dll which has to catch standard c++ library exceptions. Now I understand that when *any* object is thrown as an exception in managed c++, it is wrapped as a SEHException class instance. This seems to be the case with the standard c++ library that is thrown. It also seems to be the case that if you have a catch...
0
824
by: Epetruk | last post by:
Hello, I posted this a while back, but I have had no response yet. I have a mixed dll which has to catch standard c++ library exceptions. Now I understand that when any object is thrown as an exception in managed c++, it is wrapped as a SEHException class instance. This seems to be the case with the standard c++ library that is thrown.
7
6380
by: Derek Schuff | last post by:
I'm sorry if this is a FAQ or on an easily-accesible "RTFM" style page, but i couldnt find it. I have some code like this: for line in f: toks = line.split() try: if int(toks,16) == qaddrs+0x1000 and toks == "200": #producer write prod = int(toks, 16)
5
2221
by: Simon Tamman | last post by:
I have an object named DisasterRecovery. The Ctor of this object is this: private DisasterRecovery() { Application.ThreadException+= new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException +=new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); }
0
7912
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...
0
8338
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...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
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...
0
5390
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...
1
2345
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 we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.