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  char const* actionName(ActionCodes code) {
12  static constexpr std::array<char const*, LastCode> tab = []() constexpr {
13  std::array<char const*, LastCode> table{};
14  table[IgnoreCompletely] = "IgnoreCompletely";
15  table[Rethrow] = "Rethrow";
16  table[SkipEvent] = "SkipEvent";
17  table[FailPath] = "FailPath";
18  return table;
19  }();
20  return static_cast<unsigned int>(code) < tab.size() ? tab[code] : "UnknownAction";
21  }
22  } // namespace exception_actions
23 
25 
26  namespace {
27  inline void install(exception_actions::ActionCodes code,
29  ParameterSet const& pset) {
30  typedef std::vector<std::string> vstring;
31 
32  // we cannot have parameters in the main process section so look
33  // for an untracked (optional) ParameterSet called "options" for
34  // now. Notice that all exceptions (most actally) throw
35  // edm::Exception with the configuration category. This
36  // category should probably be more specific or a derived
37  // exception type should be used so the catch can be more
38  // specific.
39 
40  // cerr << pset.toString() << std::endl;
41 
42  ParameterSet const& opts = pset.getUntrackedParameterSet("options");
43  //cerr << "looking for " << actionName(code) << std::endl;
44  for (auto const& v : opts.getUntrackedParameter<std::vector<std::string>>(actionName(code))) {
45  out[v] = code;
46  }
47  }
48  } // namespace
49 
51  addDefaults();
52 
57  }
58 
60  // populate defaults that are not 'Rethrow'
61  // (There are none as of CMSSW_3_4_X.)
62  // 'Rethrow' is the default default.
63  if (2 <= debugit()) {
64  ActionMap::const_iterator ib(map_.begin()), ie(map_.end());
65  for (; ib != ie; ++ib) {
66  std::cerr << ib->first << ',' << ib->second << '\n';
67  }
68  std::cerr << std::endl;
69  }
70  }
71 
73 
75  map_[category] = code;
76  }
77 
79  ActionMap::const_iterator i(map_.find(category));
80  return i != map_.end() ? i->second : exception_actions::Rethrow;
81  }
82 
83 } // namespace edm
debugvalue debugit
Definition: DebugMacros.cc:10
void add(const std::string &category, exception_actions::ActionCodes code)
exception_actions::ActionCodes find(const std::string &category) const
HLT enums.
std::map< std::string, exception_actions::ActionCodes > ActionMap
std::vector< std::string > vstring
Definition: Schedule.cc:482
ib
Definition: cuy.py:661
const char * actionName(ActionCodes code)