LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Disturbance_module.cc
Go to the documentation of this file.
1 
9 // framework libraries
13 #include "fhiclcpp/types/Atom.h"
14 
15 namespace lar {
16  namespace example {
17 
31  class Disturbance : public art::EDProducer {
32  public:
33  struct Config {
34 
36  fhicl::Comment("number of exceptions to throw")};
37 
38  }; // struct Config
39 
41 
43  Disturbance(Parameters const& config);
44 
46  virtual void produce(art::Event&) override;
47 
48  private:
49  unsigned int fNArtExceptions;
50 
52  static void throwArtException();
53 
54  }; // class Disturbance
55 
56  } // namespace example
57 } // namespace lar
58 
59 //------------------------------------------------------------------------------
61  : EDProducer{config}, fNArtExceptions(config().NArtExceptions())
62 {}
63 
64 //------------------------------------------------------------------------------
66 {
67 
68  //
69  // art::Exception
70  //
71  for (unsigned int i = 0; i < fNArtExceptions; ++i) {
72  try {
74  }
75  catch (art::Exception const&) {
76  }
77  } // for
78 
79 } // lar::example::Disturbance::produce()
80 
81 //------------------------------------------------------------------------------
83 {
84 
85  throw art::Exception(art::errors::LogicError) << "I want to annoy you.\n";
86 
87 } // lar::example::Disturbance::throwArtException()
88 
89 //------------------------------------------------------------------------------
91 
92 //------------------------------------------------------------------------------
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
fhicl::Atom< unsigned int > NArtExceptions
virtual void produce(art::Event &) override
Executes the iterations.
static void throwArtException()
Throws a std::out_of_range exception.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
LArSoft-specific namespace.
Disturbance(Parameters const &config)
Constructor.