#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::Exception > | accumulatedExceptions_ |
std::auto_ptr< cms::Exception > | firstException_ |
std::string | initialMessage_ |
int | nExceptions_ |
Definition at line 34 of file ExceptionCollector.h.
edm::ExceptionCollector::ExceptionCollector | ( | std::string const & | initialMessage | ) |
Definition at line 9 of file ExceptionCollector.cc.
: initialMessage_(initialMessage), firstException_(), accumulatedExceptions_(), nExceptions_(0) { }
edm::ExceptionCollector::~ExceptionCollector | ( | ) |
Definition at line 16 of file ExceptionCollector.cc.
{ }
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().
{ ++nExceptions_; if (nExceptions_ == 1) { firstException_.reset(exception.clone()); accumulatedExceptions_.reset(new cms::Exception("MultipleExceptions", initialMessage_)); } *accumulatedExceptions_ << "----- Exception " << nExceptions_ << " -----" << "\n" << exception.explainSelf(); }
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(), exception, cms::Exception::explainSelf(), f, firstException_, initialMessage_, nExceptions_, asciidump::s, edm::convertException::stdToEDM(), edm::convertException::stringToEDM(), and edm::convertException::unknownToEDM().
Referenced by edm::EventProcessor::endJob().
{ try { try { f(); } catch (cms::Exception& e) { throw; } catch (std::bad_alloc& bda) { convertException::badAllocToEDM(); } catch (std::exception& e) { convertException::stdToEDM(e); } catch (std::string& s) { convertException::stringToEDM(s); } catch (char const* c) { convertException::charPtrToEDM(c); } catch (...) { convertException::unknownToEDM(); } } catch (cms::Exception const& ex) { ++nExceptions_; if (nExceptions_ == 1) { firstException_.reset(ex.clone()); accumulatedExceptions_.reset(new cms::Exception("MultipleExceptions", initialMessage_)); } *accumulatedExceptions_ << nExceptions_ << "\n" << ex.explainSelf(); } }
bool edm::ExceptionCollector::hasThrown | ( | ) | const |
Definition at line 20 of file ExceptionCollector.cc.
References nExceptions_.
Referenced by edm::EventProcessor::endJob(), and edm::SubProcess::endJob().
{ return nExceptions_ > 0; }
void edm::ExceptionCollector::rethrow | ( | void | ) | const |
Definition at line 25 of file ExceptionCollector.cc.
References accumulatedExceptions_, firstException_, and nExceptions_.
Referenced by edm::EventProcessor::endJob(), and edm::SubProcess::endJob().
{ if (nExceptions_ == 1) { firstException_->raise(); } else if (nExceptions_ > 1) { accumulatedExceptions_->raise(); } }
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().