Re: Review: Boost Test Library
by other posts by this author
Feb 13 2001 9:57PM messages near this date
Re: Review: Boost Test Library
|
Re: [boost] Re: Review: Boost Test Library
Just a thought to spark others creativity...
I've been thinking a bit about the desire for catch_exceptions() to
be able to handle registered exception types (during my breaks from
documenting the BTL, which should be done in a day or two for those
who are helping me finalize this before submitting), and a trick
suggested on a programming site I read in the past came to mind
(sorry, I can't give exact credit here). Error handling functions
can be registered and called from catch blocks by using the following
idiom:
bool handle_my_error_types()
{
try
{
throw; // re-throw the last exception
}
catch (my_specific_error_type err)
{
// handle the error
return true; // we handled the error
}
catch (...)
{
return false; // we didn't handle the error
}
}
void example()
{
try
{
// some code that throws
}
catch (...)
{
if (handle_my_error_types())
cout << handled << endl;
else
cout << unknown exception type << endl;
}
}
I think that this idiom could be used to allow test programs
to push handlers for specific exception types that they used onto
a handler stack that would be used by catch_exceptions(). This
should allow for very specific reports about what exceptions are
caught by the test framework, even though the framework is not aware
of library defined exception types.
The one caveat is that (at the time I found this idiom at least) VC++
couldn't handle this (it tries to destruct the exceptions multiple
times!).
Any thoughts or comments on the idea?
Bill Kempf
Thread:
Jens Maurer
Ed Brey
Beman Dawes
Jens Maurer
Beman Dawes
Jens Maurer
Jens Maurer
David Abrahams
David Abrahams
Mark Rodgers
Kevlin Henney
Kevlin Henney
Ronald Garcia
Mark Rodgers
Ed Brey
David Abrahams
David Abrahams
David Abrahams
Beman Dawes
Ed Brey
Jens Maurer
Beman Dawes
Ed Brey
|