|
-
June 6th, 2007, 01:51 AM
#1
print information about unknown exceptions
Hello,
is it possible to get some information about an unknown (or unexpected) exception?
e.g
try{
//...do something
}
catch(...)
{
//print some information
}
in this case I want to know which exception was thrown..in other languages (java, c#...) this is possible. But I'm not sure if it is also possible in c++
Best regards
Hansjörg
-
June 6th, 2007, 04:31 AM
#2
Re: print information about unknown exceptions
If you use ... it's not possible. You are ignoring the exception type and then want to know what exeption?
-
June 6th, 2007, 05:49 AM
#3
Re: print information about unknown exceptions
There's no given base interface/class/pattern that exceptions must follow, so nope. Usually exceptions are derived from std::exception though, so you could do something such as:
Code:
try
{
// ...
}
catch (std::exception& e)
{
// Log exception with information provided from e.what()
}
catch (...)
{
// Log exception with a message such as "unknown exception"
}
-
June 6th, 2007, 07:14 AM
#4
Re: print information about unknown exceptions
There are some libraries, example Roguewave - where the base exception class is not std::exception but one of their own, so if you are using different libraries - make sure you don't miss their base catches.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
June 6th, 2007, 08:22 AM
#5
Re: print information about unknown exceptions
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|