CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
edm::ExceptionCollector Class Reference

#include <ExceptionCollector.h>

Public Member Functions

void addException (cms::Exception const &exception)
 
void call (boost::function< void(void)>)
 
 ExceptionCollector (std::string const &initialMessage)
 
bool hasThrown () const
 
void rethrow () const
 
 ~ExceptionCollector ()
 

Private Attributes

std::auto_ptr< cms::ExceptionaccumulatedExceptions_
 
std::auto_ptr< cms::ExceptionfirstException_
 
std::string initialMessage_
 
int nExceptions_
 

Detailed Description

Definition at line 34 of file ExceptionCollector.h.

Constructor & Destructor Documentation

edm::ExceptionCollector::ExceptionCollector ( std::string const &  initialMessage)

Definition at line 9 of file ExceptionCollector.cc.

9  :
10  initialMessage_(initialMessage),
13  nExceptions_(0) {
14  }
std::auto_ptr< cms::Exception > accumulatedExceptions_
std::auto_ptr< cms::Exception > firstException_
edm::ExceptionCollector::~ExceptionCollector ( )

Definition at line 16 of file ExceptionCollector.cc.

16  {
17  }

Member Function Documentation

void edm::ExceptionCollector::addException ( cms::Exception const &  exception)

Definition at line 59 of file ExceptionCollector.cc.

References accumulatedExceptions_, cms::Exception::clone(), cms::Exception::explainSelf(), firstException_, initialMessage_, and nExceptions_.

Referenced by edm::Schedule::endJob().

59  {
60  ++nExceptions_;
61  if (nExceptions_ == 1) {
62  firstException_.reset(exception.clone());
63  accumulatedExceptions_.reset(new cms::Exception("MultipleExceptions", initialMessage_));
64  }
65  *accumulatedExceptions_ << "----- Exception " << nExceptions_ << " -----"
66  << "\n"
67  << exception.explainSelf();
68  }
std::auto_ptr< cms::Exception > accumulatedExceptions_
std::auto_ptr< cms::Exception > firstException_
void edm::ExceptionCollector::call ( boost::function< void(void)>  f)

Definition at line 35 of file ExceptionCollector.cc.

References accumulatedExceptions_, edm::convertException::badAllocToEDM(), trackerHits::c, edm::convertException::charPtrToEDM(), cms::Exception::clone(), alignCSCRings::e, cppFunctionSkipper::exception, cms::Exception::explainSelf(), f, firstException_, initialMessage_, nExceptions_, alignCSCRings::s, edm::convertException::stdToEDM(), AlCaHLTBitMon_QueryRunRegistry::string, edm::convertException::stringToEDM(), and edm::convertException::unknownToEDM().

Referenced by edm::EventProcessor::endJob().

35  {
36  try {
37  try {
38  f();
39  }
40  catch (cms::Exception& e) { throw; }
41  catch (std::bad_alloc& bda) { convertException::badAllocToEDM(); }
44  catch (char const* c) { convertException::charPtrToEDM(c); }
45  catch (...) { convertException::unknownToEDM(); }
46  }
47  catch (cms::Exception const& ex) {
48  ++nExceptions_;
49  if (nExceptions_ == 1) {
50  firstException_.reset(ex.clone());
51  accumulatedExceptions_.reset(new cms::Exception("MultipleExceptions", initialMessage_));
52  }
54  << ex.explainSelf();
55  }
56  }
virtual std::string explainSelf() const
Definition: Exception.cc:146
void stdToEDM(std::exception const &e)
std::auto_ptr< cms::Exception > accumulatedExceptions_
double f[11][100]
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
virtual Exception * clone() const
Definition: Exception.cc:259
std::auto_ptr< cms::Exception > firstException_
bool edm::ExceptionCollector::hasThrown ( ) const

Definition at line 20 of file ExceptionCollector.cc.

References nExceptions_.

Referenced by edm::EventProcessor::endJob(), and edm::SubProcess::endJob().

20  {
21  return nExceptions_ > 0;
22  }
void edm::ExceptionCollector::rethrow ( ) const

Definition at line 25 of file ExceptionCollector.cc.

References accumulatedExceptions_, firstException_, and nExceptions_.

Referenced by edm::EventProcessor::endJob(), and edm::SubProcess::endJob().

25  {
26  if (nExceptions_ == 1) {
27  firstException_->raise();
28  }
29  else if (nExceptions_ > 1) {
30  accumulatedExceptions_->raise();
31  }
32  }
std::auto_ptr< cms::Exception > accumulatedExceptions_
std::auto_ptr< cms::Exception > firstException_

Member Data Documentation

std::auto_ptr<cms::Exception> edm::ExceptionCollector::accumulatedExceptions_
private

Definition at line 46 of file ExceptionCollector.h.

Referenced by addException(), call(), and rethrow().

std::auto_ptr<cms::Exception> edm::ExceptionCollector::firstException_
private

Definition at line 45 of file ExceptionCollector.h.

Referenced by addException(), call(), and rethrow().

std::string edm::ExceptionCollector::initialMessage_
private

Definition at line 44 of file ExceptionCollector.h.

Referenced by addException(), and call().

int edm::ExceptionCollector::nExceptions_
private

Definition at line 47 of file ExceptionCollector.h.

Referenced by addException(), call(), hasThrown(), and rethrow().