CMS 3D CMS Logo

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 (std::function< void(void)>)
 
 ExceptionCollector (std::string const &initialMessage)
 
bool hasThrown () const
 
void rethrow () const
 
 ~ExceptionCollector ()
 

Private Attributes

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

Detailed Description

Definition at line 33 of file ExceptionCollector.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file ExceptionCollector.cc.

28  :
29  initialMessage_(initialMessage),
32  nExceptions_(0) {
33  }
std::unique_ptr< cms::Exception > firstException_
std::unique_ptr< cms::Exception > accumulatedExceptions_
edm::ExceptionCollector::~ExceptionCollector ( )

Definition at line 35 of file ExceptionCollector.cc.

35  {
36  }

Member Function Documentation

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

Definition at line 72 of file ExceptionCollector.cc.

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

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

72  {
73  ++nExceptions_;
74  if (nExceptions_ == 1) {
75  firstException_.reset(exception.clone());
76  accumulatedExceptions_.reset(new MultipleException(exception.returnCode(), initialMessage_));
77  }
78  *accumulatedExceptions_ << "----- Exception " << nExceptions_ << " -----"
79  << "\n"
80  << exception.explainSelf();
81  }
std::unique_ptr< cms::Exception > firstException_
std::unique_ptr< cms::Exception > accumulatedExceptions_
void edm::ExceptionCollector::call ( std::function< void(void)>  f)

Definition at line 54 of file ExceptionCollector.cc.

References accumulatedExceptions_, cms::Exception::clone(), cms::Exception::explainSelf(), f, firstException_, initialMessage_, nExceptions_, cms::Exception::returnCode(), and edm::convertException::wrap().

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

54  {
55  try {
57  f();
58  });
59  }
60  catch (cms::Exception const& ex) {
61  ++nExceptions_;
62  if (nExceptions_ == 1) {
63  firstException_.reset(ex.clone());
64  accumulatedExceptions_.reset(new MultipleException(ex.returnCode(), initialMessage_));
65  }
67  << ex.explainSelf();
68  }
69  }
std::unique_ptr< cms::Exception > firstException_
virtual std::string explainSelf() const
Definition: Exception.cc:146
double f[11][100]
int returnCode() const
Definition: Exception.cc:199
std::unique_ptr< cms::Exception > accumulatedExceptions_
auto wrap(F iFunc) -> decltype(iFunc())
virtual Exception * clone() const
Definition: Exception.cc:259
bool edm::ExceptionCollector::hasThrown ( ) const

Definition at line 39 of file ExceptionCollector.cc.

References nExceptions_.

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

39  {
40  return nExceptions_ > 0;
41  }
void edm::ExceptionCollector::rethrow ( ) const

Definition at line 44 of file ExceptionCollector.cc.

References accumulatedExceptions_, firstException_, and nExceptions_.

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

44  {
45  if (nExceptions_ == 1) {
46  firstException_->raise();
47  }
48  else if (nExceptions_ > 1) {
49  accumulatedExceptions_->raise();
50  }
51  }
std::unique_ptr< cms::Exception > firstException_
std::unique_ptr< cms::Exception > accumulatedExceptions_

Member Data Documentation

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

Definition at line 45 of file ExceptionCollector.h.

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

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

Definition at line 44 of file ExceptionCollector.h.

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

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

Definition at line 43 of file ExceptionCollector.h.

Referenced by addException(), and call().

int edm::ExceptionCollector::nExceptions_
private

Definition at line 46 of file ExceptionCollector.h.

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