ThrowingProducer_module.cc
Go to the documentation of this file.
5 #include "fhiclcpp/types/Atom.h"
6 
7 namespace art {
8  namespace test {
9 
10  class ThrowingProducer : public EDProducer {
11  unsigned count_{};
12  unsigned const threshold_;
13 
14  public:
16 
18  : EDProducer{p}, threshold_{p().throwAfter()}
19  {
20  if (p().throwFromCtor()) {
21  throw Exception{errors::OtherArt} << "Throw from c'tor.\n";
22  }
23  }
24 
25  private:
26  void
27  produce(Event&) override
28  {
29  ++count_;
30  if (count_ >= threshold_) {
31  throw Exception{errors::OtherArt} << "Throw from produce.\n";
32  }
33  }
34  };
35 
36  } // namespace test
37 } // namespace art
38 
Definition: test.py:1
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
p
Definition: test.py:228
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66