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 defopts;
52  ParameterSet const& opts = pset.getUntrackedParameterSet("options", defopts);
53  //cerr << "looking for " << actionName(code) << std::endl;
54  for(auto const& v: opts.getUntrackedParameter(actionName(code),vstring())) {
55  out[v] = code;
56  }
57 
58  }
59  }
60 
62  addDefaults();
63 
64  install(exception_actions::SkipEvent, map_, pset);
65  install(exception_actions::Rethrow, map_, pset);
67  install(exception_actions::FailPath, map_, pset);
68  }
69 
71  // populate defaults that are not 'Rethrow'
72  // (There are none as of CMSSW_3_4_X.)
73  // 'Rethrow' is the default default.
74  if(2 <= debugit()) {
75  ActionMap::const_iterator ib(map_.begin()),ie(map_.end());
76  for(;ib != ie; ++ib) {
77  std::cerr << ib->first << ',' << ib->second << '\n';
78  }
79  std::cerr << std::endl;
80  }
81  }
82 
84  }
85 
87  map_[category] = code;
88  }
89 
91  ActionMap::const_iterator i(map_.find(category));
92  return i != map_.end() ? i->second : exception_actions::Rethrow;
93  }
94 
95 }
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:660