473,395 Members | 1,652 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,395 software developers and data experts.

type info of exception

Is it possible to portably get the typename of an exception
that occurred?

I noticed when an uncaught exception occurred, GCC (3.4.1)
displayed:

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid

So I tried:

catch(std::exception &e) {
std::cerr << "[E] Exception (" << typeid(e).name()
<< ") thrown: " << e.what() << std::endl;
}
but got output:
[E] Exception (St11logic_error) thrown:
basic_string::_S_construct NULL not valid

ie. it said St11logic_error instead of std::logic_error. Do
I have to try using a compiler-specific unmangling function?
Jul 22 '05 #1
1 3461

"Old Wolf" wrote:
that occurred?

I noticed when an uncaught exception occurred, GCC (3.4.1)
displayed:

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid

So I tried:

catch(std::exception &e) {
std::cerr << "[E] Exception (" << typeid(e).name()
<< ") thrown: " << e.what() << std::endl;
}
but got output:
[E] Exception (St11logic_error) thrown:
basic_string::_S_construct NULL not valid

ie. it said St11logic_error instead of std::logic_error. Do
I have to try using a compiler-specific unmangling function?


In the C++ standard, under 18.5.1[8], the return of
std::type_info::name() is
implementation-defined. This means that some compilers might chose to
return
"std::logic_error", some might have some specific mangled name for it
(such as
it is in your case) or some might even return an empty string.

Vladimir Ciobanu
Jul 22 '05 #2

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

Similar topics

10
by: Frank | last post by:
Using Python 2.2.2, I want to catch all exceptions from "socket.gethostbyaddr(ip)" From IDLE, I can generate: >>> socket.gethostbyaddr('1.2') Traceback (most recent call last): File...
21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
1
by: Chris | last post by:
I have seen the posts on various places on the internet about .NET framework mismatch issues and I don't think that is my problem. ; ) When I execute the following C++.NET code: String...
1
by: Opa | last post by:
Hi I'm having problem serialization an object instance which contains a public property on the object type My object hierarchy is many levels deep, so for simplicty I created to following which...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the...
1
by: Lenn | last post by:
Hello, Here's a little background. I have a function that calls a method of another assembly (COM Interop) dynamically through Reflection. It gets method name and array of values and calls...
12
by: daz_oldham | last post by:
Hi everyone As my expedition into OOP takes another shaky step, I now am getting the error: An unhandled exception of type 'System.StackOverflowException' occurred in xxx.dll. In my...
4
by: Dan Manges | last post by:
Given a type as a string, is there an easy way using reflection to find where it resides in the .NET framework? Example: Given "XmlNode", get "System.Xml" Given "ArrayList", get...
20
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
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...

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.