Hi all!
Is it possible to identify throw statement, within catch( ... )?
Can I identify type of exception passed to catch(...) ?
I'm trying to identify problem, which is probably somewhere in library
which I'm using.
This is real-time program, so step-by-step debbuging is very diffcult.
Program is written in gcc-3.3 working on Linux
best regards
Jarek. 11 2277
> Hi all! Is it possible to identify throw statement, within catch( ... )? Can I identify type of exception passed to catch(...) ? I'm trying to identify problem, which is probably somewhere in library which I'm using. This is real-time program, so step-by-step debbuging is very diffcult. Program is written in gcc-3.3 working on Linux
best regards Jarek.
If all you can do to catch the exception is through catch(...) then the only
assumption your handling code should make is that an exception is thrown. If
the exception itself is polymorphic and you know the base type then you can
use RTTI (e.g. dynamic_cast, typeid(), etc)
ben
I'm not recommending this approach but...
If you explictly throw then you can use the __LINE__ and __FILE__
preprocessor directives either to create an object, or if you are
abandoning any sanity set a global variable.
If you do this, then I wany joint credit in the obfuscated C++ contest
:)
benben wrote: If all you can do to catch the exception is through catch(...) then the only assumption your handling code should make is that an exception is thrown. If the exception itself is polymorphic and you know the base type then you can use RTTI (e.g. dynamic_cast, typeid(), etc)
The problem is that I don't know anything about this exception. I tried
few catch-es (exception, char *, etc), but no one can match.
Is there some tool to analyze to analyze code to find all throws ?
Something like in eclipse for java ?
best regards
Jarek
> The problem is that I don't know anything about this exception. I tried few catch-es (exception, char *, etc), but no one can match.
So doesn't the library documentation specifies the types to be thrown? also
check exception specification in function declarations.
benben wrote: The problem is that I don't know anything about this exception. I tried few catch-es (exception, char *, etc), but no one can match.
So doesn't the library documentation specifies the types to be thrown? also check exception specification in function declarations.
It is not clear, and code doesn't match manuals.
I'm studying now what Bjarne Stroustrup in his C++ book is thinking
about this :)
Thank you are any sugestions.
best regards
Jarek.
I think, as benben said, your best bet is to use RTTI.
>I think, as benben said, your best bet is to use RTTI.
But RTTI relies on a pointer being thrown. Most systems don't throw pointers
anymore.
That's why it is always a good idea to have an exception hierarchical
exception family...
Ben
benben schreef: I think, as benben said, your best bet is to use RTTI.
But RTTI relies on a pointer being thrown. Most systems don't throw pointers anymore.
No it doesn't. RTTI works on pointers and references. You can catch
by reference, so that will allow you to catch non-pointers. That
doesn't
solve an undocumented exeption/catch(...) problem, though.
HTH,
Michiel Salters
> No it doesn't. RTTI works on pointers and references. You can catch by reference, so that will allow you to catch non-pointers. That doesn't solve an undocumented exeption/catch(...) problem, though.
HTH, Michiel Salters
But you can't have a void& can you. The fact is, dumping the exception
requires assumption on where the exception object is actually stored.
Ben This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DraguVaso |
last post by:
Hi,
I want my application do different actions depending on the exception it
gets.
For exemple: I have an SQL-table with a unique index. In case I try to
Insert a record that's alreaddy in it I get this exception: "Cannot insert
duplicate key row in object 'tblTelephones' with unique index
'UniqueValues'."
What I'm looking for is a way to identify the exception: in case I get this
|
by: Pieter |
last post by:
Hi,
For some procedures that throws exceptions, I would like to show different
messages to the user depending on what type of exception he's getting. For
instance this one: when the file is locked, I want a messagebox to tell that
the user has to close the file first.
Is there a way to identify an exception by some kind of unique number or
something like this? I don't want to identify it on the Exception Message
because some users are...
|
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...
|
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...
|
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...
| |
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,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |