Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > type info of exception

Reply
Thread Tools

type info of exception

 
 
Old Wolf
Guest
Posts: n/a
 
      08-30-2004
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?
 
Reply With Quote
 
 
 
 
Vladimir Ciobanu
Guest
Posts: n/a
 
      08-30-2004

"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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
how to show C line number AND exception type in JNI exception stacktrace? Elaine Cheong Java 1 12-09-2006 08:59 AM
Exception of type System.Exception was thrown Selen ASP .Net 0 05-28-2004 07:19 AM
Re: Type casting- a larger type to a smaller type heyo C Programming 3 04-01-2004 06:35 PM



Advertisments