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
void addException(cms::Exception const &exception)
std::unique_ptr< cms::Exception > firstException_
virtual std::string explainSelf() const
Definition: Exception.cc:108
Exception * clone() const override
double f[11][100]
int returnCode_() const override
Namespace of DDCMS conversion namespace.
int returnCode() const
Definition: Exception.cc:151
std::unique_ptr< cms::Exception > accumulatedExceptions_
ExceptionCollector(std::string const &initialMessage)
HLT enums.
auto wrap(F iFunc) -> decltype(iFunc())
void call(std::function< void(void)>)
MultipleException(int iReturnValue, std::string const &iMessage)
virtual Exception * clone() const
Definition: Exception.cc:181