CMS 3D CMS Logo

ExceptionActions.cc
Go to the documentation of this file.
1 
5 
6 #include <vector>
7 #include <iostream>
8 
9 namespace edm {
10  namespace exception_actions {
11  namespace {
12  struct ActionNames {
13  ActionNames():table_(LastCode + 1) {
14  table_[IgnoreCompletely] = "IgnoreCompletely";
15  table_[Rethrow] = "Rethrow";
16  table_[SkipEvent] = "SkipEvent";
17  table_[FailPath] = "FailPath";
18  }
19 
20  typedef std::vector<char const*> Table;
21  Table table_;
22  };
23  }
24 
25  char const* actionName(ActionCodes code) {
26  static ActionNames tab;
27  return static_cast<unsigned int>(code) < tab.table_.size() ? tab.table_[code] : "UnknownAction";
28  }
29  }
30 
32  addDefaults();
33  }
34 
35  namespace {
36  inline void install(exception_actions::ActionCodes code,
38  ParameterSet const& pset) {
39  typedef std::vector<std::string> vstring;
40 
41  // we cannot have parameters in the main process section so look
42  // for an untracked (optional) ParameterSet called "options" for
43  // now. Notice that all exceptions (most actally) throw
44  // edm::Exception with the configuration category. This
45  // category should probably be more specific or a derived
46  // exception type should be used so the catch can be more
47  // specific.
48 
49 // cerr << pset.toString() << std::endl;
50 
51  ParameterSet const& opts = pset.getUntrackedParameterSet("options");
52  //cerr << "looking for " << actionName(code) << std::endl;
53  for(auto const& v: opts.getUntrackedParameter<std::vector<std::string>>(actionName(code))) {
54  out[v] = code;
55  }
56 
57  }
58  }
59 
61  addDefaults();
62 
63  install(exception_actions::SkipEvent, map_, pset);
64  install(exception_actions::Rethrow, map_, pset);
66  install(exception_actions::FailPath, map_, pset);
67  }
68 
70  // populate defaults that are not 'Rethrow'
71  // (There are none as of CMSSW_3_4_X.)
72  // 'Rethrow' is the default default.
73  if(2 <= debugit()) {
74  ActionMap::const_iterator ib(map_.begin()),ie(map_.end());
75  for(;ib != ie; ++ib) {
76  std::cerr << ib->first << ',' << ib->second << '\n';
77  }
78  std::cerr << std::endl;
79  }
80  }
81 
83  }
84 
86  map_[category] = code;
87  }
88 
90  ActionMap::const_iterator i(map_.find(category));
91  return i != map_.end() ? i->second : exception_actions::Rethrow;
92  }
93 
94 }
Map map_
T getUntrackedParameter(std::string const &, T const &) const
debugvalue debugit
Definition: DebugMacros.cc:13
exception_actions::ActionCodes find(const std::string &category) const
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void add(const std::string &category, exception_actions::ActionCodes code)
const char * actionName(ActionCodes code)
Table table_
HLT enums.
std::map< std::string, exception_actions::ActionCodes > ActionMap
std::vector< std::string > vstring
Definition: Schedule.cc:430
ib
Definition: cuy.py:661