473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

how to catch uncaught exception

hi all,
i am facing a problem in catching an exception which is uncaught in any
of the catch block.
not doing so will gives me coredump.
I tried by rewriting set_unexpected() and set_terminate() function.
But these works fine only for small programs.
when i tried with my large applications which links to n num of
different libraries, it doesnot work.
so please help me to handle uncaught exception on any of the UNIX
flavors(it will be more helpful ,if it is AIX5.2).
please help me ASAP.
Thanks in advance.

Thanks & Regards
Nagaraj Hayyal

Jul 23 '05 #1
4 3162


nrhayyal schreef:
hi all,
i am facing a problem in catching an exception which is uncaught in any
of the catch block.


catch(...) will catch any C++ exception. You can't access the caught
object, though - for that you need the type.

You cannot catch a CPU exception, but that would of course be off-topic
here. C++ doesn't deal with those.

HTH,
Michiel Salters

Jul 23 '05 #2
Me
> i am facing a problem in catching an exception which is uncaught in any
of the catch block.
not doing so will gives me coredump.
I tried by rewriting set_unexpected() and set_terminate() function.
But these works fine only for small programs.
when i tried with my large applications which links to n num of
different libraries, it doesnot work.
so please help me to handle uncaught exception on any of the UNIX
flavors(it will be more helpful ,if it is AIX5.2).


Riiiight. Why don't you find out what is throwing the exception in your
callstack and either fix it not to throw the exception (and by that I
don't mean removing the throw statement) or handle it by catching the
type explicitly. This program is behaving exactly like it was designed
to do and I highly suggest you do not hack around it by playing with
set_unexpected/set_terminate/catch(...) or it will be even more
difficult to fix and debug. So what you need to do is figure out how to
get a callstack trace from this coredump (don't ask me, I'm on windows)
or something similar and go from there.

Unless you meant a hardware exception. C++ doesn't deal with those
kinds in its exception handling model but getting a stack trace from
the coredump would help you find the offending code anyway.

Jul 23 '05 #3
thanks michiel for ur instant reply and thanks to "Me" for ur instant
reply also.
i have a catch(...) in my program ,but still its not caught in that
block.
let me explain the problem by putting few more details.

suppose if i have a program p1 which has main().
in p1 i have different types of catch blocks along with catch(...)
in the try block of p1, i am calling one of the functions of p2, in p2
i am calling p3 func(), in p3 i am calling p4 func() and so on upto
p10.
all these p2-p10 are programs.
these programs are built and kept it as library functions , assume
p2.a, p3.a .....p10.a.
all these libraries are linked in the makefile of p1 and p1 is now my
executable( or binary file u can say).
i have no try-catch block in any of these libs.
i have only throw statements in all these libs.

so when an exception is thrown from p10.a library...... it is supposed
to be caught in any of the catch blocks in p1. if not it should be
caught atleast in catch(...).
But in my module the thrown exception is not at all caught , instead of
which i am getting coredump.
i hope the problem is clearer now.
i am using gcc-3.3.2 on AIX5.2.
please let me know solution.
thanks again to all of u friends.

thanks & regards
Nagaraj Hayyal

Jul 23 '05 #4
On Thu, 9 Jun 2005 11:08:58 UTC, "nrhayyal" <na************@satyam.com>
wrote:
thanks michiel for ur instant reply and thanks to "Me" for ur instant
reply also.
i have a catch(...) in my program ,but still its not caught in that
block.
let me explain the problem by putting few more details.

suppose if i have a program p1 which has main().
in p1 i have different types of catch blocks along with catch(...)
in the try block of p1, i am calling one of the functions of p2, in p2
i am calling p3 func(), in p3 i am calling p4 func() and so on upto
p10.
all these p2-p10 are programs.
these programs are built and kept it as library functions , assume
p2.a, p3.a .....p10.a.
all these libraries are linked in the makefile of p1 and p1 is now my
executable( or binary file u can say).
i have no try-catch block in any of these libs.
i have only throw statements in all these libs.

so when an exception is thrown from p10.a library...... it is supposed
to be caught in any of the catch blocks in p1. if not it should be
caught atleast in catch(...).
But in my module the thrown exception is not at all caught , instead of
which i am getting coredump.
i hope the problem is clearer now.
i am using gcc-3.3.2 on AIX5.2.
please let me know solution.
thanks again to all of u friends.

thanks & regards
Nagaraj Hayyal


You might want to check out the organization of your program and
the underlying libraries and check for threads that you don't know
/realize that are being created. It may be that your application
only appears to be monolithic and handled by the catch(...) in
your main code. Each new thread/fork will require a new try/catch
mechanism to be effective.

What does the coredump indicate your problem is? Are you perhaps
getting some other kind of exception?

What trace mechanism do you have besides the primary interface?
Do you know what user/data actions cause the problem? Do your
applications have some way of tracking the progress of activity.
It helps you in finding evidence that Px started and never finished.
You can then investigate the possibility that it contained the error.

David
Jul 23 '05 #5

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

Similar topics

5
by: Jacek Dziedzic | last post by:
Hi! In my main() function I have a last-resort exception construct that looks like this: int main() { try { // ... program code }
2
by: thechaosengine | last post by:
Hi everyone, Is there anyway to create some sort of catch-all in windows forms applications that could ensure that no unexpected exceptions bring down an application? For example, perhaps...
3
by: Sunny | last post by:
Hi, I have created a StringBuilder (Log) in my application that appends all the errors and exceptions in my application. I have included Catch blocks at each sensitive location in my functions. I...
37
by: clintonG | last post by:
Has somebody written any guidelines regarding how to determine when try-catch blocks should be used and where their use would or could be considered superfluous? <%= Clinton Gallagher...
7
by: Tiraman | last post by:
Hi , I am using allot the try catch in my code and the question is if it is good ? it will decrease my performance ? one more question
9
by: Michael MacDonald | last post by:
Does someone have a good site I can visit or explain the use of Try" and Catch foe exception/error handling. What is the logic behind this command and maybe an example would be great!!!! Mike_Mac...
9
by: Mr Flibble | last post by:
Hi all, happy Friday! (certainly Friday is a day worth celebrating). I have a question on try/catch design (an exciting Friday topic for sure): I can either put a try/catch block in every...
24
by: Chameleon | last post by:
Is there a possibility to create memory leak, the code below if I run the line: --------------------------------------------------------- MyClass cl = new MyClass();...
4
by: Fred | last post by:
Is it possible to use throw in javascript without try..catch? As far as I know, you must call it from within a try..catch block, or the function that calls throw must itself be called from within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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,...
0
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...

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.