C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

type info of exception

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Old Wolf
Guest





PostPosted: Mon Aug 30, 2004 1:18 am    Post subject: type info of exception Reply with quote



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?
Back to top
Vladimir Ciobanu
Guest





PostPosted: Mon Aug 30, 2004 6:35 am    Post subject: Re: type info of exception Reply with quote




"Old Wolf" wrote:
Quote:
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



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.