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