| 4 | |
| 5 | |
| 6 | CPPUNIT_NS_BEGIN |
| 7 | |
| 8 | |
| 9 | bool |
| 10 | DefaultProtector::protect( const Functor &functor, |
| 11 | const ProtectorContext &context ) |
| 12 | { |
| 13 | try |
| 14 | { |
| 15 | return functor(); |
| 16 | } |
| 17 | catch ( Exception &failure ) |
| 18 | { |
| 19 | reportFailure( context, failure ); |
| 20 | } |
| 21 | catch ( std::exception &e ) |
| 22 | { |
| 23 | std::string shortDescription( "uncaught exception of type " ); |
| 24 | #if defined(CPPUNIT_USE_TYPEINFO_NAME) |
| 25 | shortDescription += TypeInfoHelper::getClassName( typeid(e) ); |
| 26 | #else |
| 27 | shortDescription += "std::exception (or derived)."; |
| 28 | #endif |
| 29 | Message message( shortDescription, e.what() ); |
| 30 | reportError( context, message ); |
| 31 | } |
| 32 | catch ( ... ) |
| 33 | { |
| 34 | reportError( context, |
| 35 | Message( "uncaught exception of unknown type") ); |
| 36 | } |
| 37 | |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | CPPUNIT_NS_END |