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[TryToContinue] = "TryToContinue";
17  return table;
18  }();
19  return static_cast<unsigned int>(code) < tab.size() ? tab[code] : "UnknownAction";
20  }
21  } // namespace exception_actions
22 
24 
25  namespace {
26  inline void install(exception_actions::ActionCodes code,
28  ParameterSet const& pset) {
29  typedef std::vector<std::string> vstring;
30 
31  // we cannot have parameters in the main process section so look
32  // for an untracked (optional) ParameterSet called "options" for
33  // now. Notice that all exceptions (most actally) throw
34  // edm::Exception with the configuration category. This
35  // category should probably be more specific or a derived
36  // exception type should be used so the catch can be more
37  // specific.
38 
39  // cerr << pset.toString() << std::endl;
40 
41  ParameterSet const& opts = pset.getUntrackedParameterSet("options");
42  //cerr << "looking for " << actionName(code) << std::endl;
43  for (auto const& v : opts.getUntrackedParameter<std::vector<std::string>>(actionName(code))) {
44  out[v] = code;
45  }
46  }
47  } // namespace
48 
50  addDefaults();
51 
55  }
56 
58  // populate defaults that are not 'Rethrow'
59  // (There are none as of CMSSW_3_4_X.)
60  // 'Rethrow' is the default default.
61  if (2 <= debugit()) {
62  ActionMap::const_iterator ib(map_.begin()), ie(map_.end());
63  for (; ib != ie; ++ib) {
64  std::cerr << ib->first << ',' << ib->second << '\n';
65  }
66  std::cerr << std::endl;
67  }
68  }
69 
71 
73  map_[category] = code;
74  }
75 
77  ActionMap::const_iterator i(map_.find(category));
78  return i != map_.end() ? i->second : exception_actions::Rethrow;
79  }
80 
81 } // 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)