CMS 3D CMS Logo

ExceptionCollector.cc
Go to the documentation of this file.
4 
5 #include <exception>
6 
7 namespace edm {
8 
10  public:
11  MultipleException(int iReturnValue, std::string const& iMessage)
12  : cms::Exception("MultipleExceptions", iMessage), returnValue_(iReturnValue) {}
13 
14  Exception* clone() const override { return new MultipleException(*this); }
15 
16  private:
17  int returnCode_() const override { return returnValue_; }
18 
20  };
21 
23  : initialMessage_(initialMessage), firstException_(), accumulatedExceptions_(), nExceptions_(0) {}
24 
26 
27  bool ExceptionCollector::hasThrown() const { return nExceptions_ > 0; }
28 
30  if (nExceptions_ == 1) {
31  firstException_->raise();
32  } else if (nExceptions_ > 1) {
33  accumulatedExceptions_->raise();
34  }
35  }
36 
38  try {
39  convertException::wrap([&f]() { f(); });
40  } catch (cms::Exception const& ex) {
41  ++nExceptions_;
42  if (nExceptions_ == 1) {
43  firstException_.reset(ex.clone());
45  }
47  }
48  }
49 
51  ++nExceptions_;
52  if (nExceptions_ == 1) {
53  firstException_.reset(exception.clone());
55  }
56  *accumulatedExceptions_ << "----- Exception " << nExceptions_ << " -----"
57  << "\n"
58  << exception.explainSelf();
59  }
60 } // namespace edm
edm::ExceptionCollector::initialMessage_
std::string initialMessage_
Definition: ExceptionCollector.h:43
edm::ExceptionCollector::addException
void addException(cms::Exception const &exception)
Definition: ExceptionCollector.cc:50
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ExceptionCollector::accumulatedExceptions_
std::unique_ptr< cms::Exception > accumulatedExceptions_
Definition: ExceptionCollector.h:45
edm::MultipleException::clone
Exception * clone() const override
Definition: ExceptionCollector.cc:14
edm::Exception
Definition: EDMException.h:77
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::ExceptionCollector::firstException_
std::unique_ptr< cms::Exception > firstException_
Definition: ExceptionCollector.h:44
ConvertException.h
ExceptionCollector.h
edm::ExceptionCollector::call
void call(std::function< void(void)>)
Definition: ExceptionCollector.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ExceptionCollector::hasThrown
bool hasThrown() const
Definition: ExceptionCollector.cc:27
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
edm::ExceptionCollector::~ExceptionCollector
~ExceptionCollector()
Definition: ExceptionCollector.cc:25
edm::MultipleException::MultipleException
MultipleException(int iReturnValue, std::string const &iMessage)
Definition: ExceptionCollector.cc:11
edm::ExceptionCollector::nExceptions_
int nExceptions_
Definition: ExceptionCollector.h:46
edm::MultipleException::returnValue_
int returnValue_
Definition: ExceptionCollector.cc:19
edm::MultipleException::returnCode_
int returnCode_() const override
Definition: ExceptionCollector.cc:17
cms::Exception::returnCode
int returnCode() const
Definition: Exception.cc:151
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
cms::Exception::explainSelf
virtual std::string explainSelf() const
Definition: Exception.cc:108
cms::Exception::clone
virtual Exception * clone() const
Definition: Exception.cc:181
Exception.h
cms::Exception
Definition: Exception.h:70
edm::MultipleException
Definition: ExceptionCollector.cc:9
edm::ExceptionCollector::rethrow
void rethrow() const
Definition: ExceptionCollector.cc:29
edm::ExceptionCollector::ExceptionCollector
ExceptionCollector(std::string const &initialMessage)
Definition: ExceptionCollector.cc:22
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21