Boost logo

Boost Users :

Subject: Re: [Boost-users] [Test] Making use of boost::exception_diagnostic_information and friends
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-08-10 02:48:32


On Sun, Aug 9, 2009 at 1:27 PM, Gennadiy Rozental<rogeeff_at_[hidden]> wrote:
> Emil Dotchevski <emildotchevski <at> gmail.com> writes:
>
>> I'm not familiar with the test runner, but assuming that it is
>> written in C++, all it needs is something like:
>>
>> #include <boost/exception/diagnostic_information.hpp>
>> ....
>>
>> catch(...)
>> {
>>   std::cerr << boost::current_exception_diagnostic_information();
>> }
>>
>> This will print the what() message (if available) too.
>
> I want to have a bit more flexibility as to what and how I print.
> I'll need to get a hold of each component separately.

Reporting unexpected exceptions by a testing framework is pretty much
perfect use case for boost::current_exception_diagnostic_information;
if the data in the returned string is not sufficient for diagnostic
purposes, then the function itself should be modified to return a
better string.

I welcome patches (including platform-specific hacks) that would
provide more useful diagnostic information about exceptions.

> Also I want to catch boost::exception by specific clause. It should
> be fine, right? Will I need to place it first in my list of catch
> clauses? Cause AFAIK actual type will inherit both boost::exception
> and the exception type being thrown.

Since the testing framework wouldn't know anything about the exception
it's reporting, it should catch(...) and leave it up to
current_exception_diagnostic_information to provide all the
information it can dig out from whatever the current exception may be.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net