~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to third-party/cppunit/cppunit/src/cppunit/DefaultProtector.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cppunit/Exception.h>
 
2
#include <cppunit/extensions/TypeInfoHelper.h>
 
3
#include "DefaultProtector.h"
 
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 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