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  } // namespace
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  } // namespace exception_actions
30 
32 
33  namespace {
34  inline void install(exception_actions::ActionCodes code,
36  ParameterSet const& pset) {
37  typedef std::vector<std::string> vstring;
38 
39  // we cannot have parameters in the main process section so look
40  // for an untracked (optional) ParameterSet called "options" for
41  // now. Notice that all exceptions (most actally) throw
42  // edm::Exception with the configuration category. This
43  // category should probably be more specific or a derived
44  // exception type should be used so the catch can be more
45  // specific.
46 
47  // cerr << pset.toString() << std::endl;
48 
49  ParameterSet const& opts = pset.getUntrackedParameterSet("options");
50  //cerr << "looking for " << actionName(code) << std::endl;
51  for (auto const& v : opts.getUntrackedParameter<std::vector<std::string>>(actionName(code))) {
52  out[v] = code;
53  }
54  }
55  } // namespace
56 
58  addDefaults();
59 
60  install(exception_actions::SkipEvent, map_, pset);
61  install(exception_actions::Rethrow, map_, pset);
63  install(exception_actions::FailPath, map_, pset);
64  }
65 
67  // populate defaults that are not 'Rethrow'
68  // (There are none as of CMSSW_3_4_X.)
69  // 'Rethrow' is the default default.
70  if (2 <= debugit()) {
71  ActionMap::const_iterator ib(map_.begin()), ie(map_.end());
72  for (; ib != ie; ++ib) {
73  std::cerr << ib->first << ',' << ib->second << '\n';
74  }
75  std::cerr << std::endl;
76  }
77  }
78 
80 
82  map_[category] = code;
83  }
84 
86  ActionMap::const_iterator i(map_.find(category));
87  return i != map_.end() ? i->second : exception_actions::Rethrow;
88  }
89 
90 } // namespace edm
T getUntrackedParameter(std::string const &, T const &) const
debugvalue debugit
Definition: DebugMacros.cc:10
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:567
ib
Definition: cuy.py:662