Blame src/cppunit/DefaultProtector.cpp
|
Packit |
8c9aa0 |
#include <cppunit/Exception.h>
|
|
Packit |
8c9aa0 |
#include <cppunit/extensions/TypeInfoHelper.h>
|
|
Packit |
8c9aa0 |
#include "DefaultProtector.h"
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
CPPUNIT_NS_BEGIN
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
bool
|
|
Packit |
8c9aa0 |
DefaultProtector::protect( const Functor &functor,
|
|
Packit |
8c9aa0 |
const ProtectorContext &context )
|
|
Packit |
8c9aa0 |
{
|
|
Packit |
8c9aa0 |
try
|
|
Packit |
8c9aa0 |
{
|
|
Packit |
8c9aa0 |
return functor();
|
|
Packit |
8c9aa0 |
}
|
|
Packit |
8c9aa0 |
catch ( Exception &failure )
|
|
Packit |
8c9aa0 |
{
|
|
Packit |
8c9aa0 |
reportFailure( context, failure );
|
|
Packit |
8c9aa0 |
}
|
|
Packit |
8c9aa0 |
catch ( std::exception &e )
|
|
Packit |
8c9aa0 |
{
|
|
Packit |
8c9aa0 |
std::string shortDescription( "uncaught exception of type " );
|
|
Packit |
8c9aa0 |
#if defined(CPPUNIT_USE_TYPEINFO_NAME)
|
|
Packit |
8c9aa0 |
shortDescription += TypeInfoHelper::getClassName( typeid(e) );
|
|
Packit |
8c9aa0 |
#else
|
|
Packit |
8c9aa0 |
shortDescription += "std::exception (or derived).";
|
|
Packit |
8c9aa0 |
#endif
|
|
Packit |
8c9aa0 |
Message message( shortDescription, e.what() );
|
|
Packit |
8c9aa0 |
reportError( context, message );
|
|
Packit |
8c9aa0 |
}
|
|
Packit |
8c9aa0 |
catch ( ... )
|
|
Packit |
8c9aa0 |
{
|
|
Packit |
8c9aa0 |
reportError( context,
|
|
Packit |
8c9aa0 |
Message( "uncaught exception of unknown type") );
|
|
Packit |
8c9aa0 |
}
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
return false;
|
|
Packit |
8c9aa0 |
}
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
|
|
Packit |
8c9aa0 |
CPPUNIT_NS_END
|