File indexing completed on 2022-12-03 01:06:15
0001
0002 #include "FWCore/Framework/interface/ExceptionActions.h"
0003 #include "FWCore/Utilities/interface/DebugMacros.h"
0004 #include "FWCore/Utilities/interface/Algorithms.h"
0005
0006 #include <vector>
0007 #include <iostream>
0008
0009 namespace edm {
0010 namespace exception_actions {
0011 char const* actionName(ActionCodes code) {
0012 static constexpr std::array<char const*, LastCode> tab = []() constexpr {
0013 std::array<char const*, LastCode> table{};
0014 table[IgnoreCompletely] = "IgnoreCompletely";
0015 table[Rethrow] = "Rethrow";
0016 table[SkipEvent] = "SkipEvent";
0017 table[FailPath] = "FailPath";
0018 return table;
0019 }
0020 ();
0021 return static_cast<unsigned int>(code) < tab.size() ? tab[code] : "UnknownAction";
0022 }
0023 }
0024
0025 ExceptionToActionTable::ExceptionToActionTable() : map_() { addDefaults(); }
0026
0027 namespace {
0028 inline void install(exception_actions::ActionCodes code,
0029 ExceptionToActionTable::ActionMap& out,
0030 ParameterSet const& pset) {
0031 typedef std::vector<std::string> vstring;
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 ParameterSet const& opts = pset.getUntrackedParameterSet("options");
0044
0045 for (auto const& v : opts.getUntrackedParameter<std::vector<std::string>>(actionName(code))) {
0046 out[v] = code;
0047 }
0048 }
0049 }
0050
0051 ExceptionToActionTable::ExceptionToActionTable(ParameterSet const& pset) : map_() {
0052 addDefaults();
0053
0054 install(exception_actions::SkipEvent, map_, pset);
0055 install(exception_actions::Rethrow, map_, pset);
0056 install(exception_actions::IgnoreCompletely, map_, pset);
0057 install(exception_actions::FailPath, map_, pset);
0058 }
0059
0060 void ExceptionToActionTable::addDefaults() {
0061
0062
0063
0064 if (2 <= debugit()) {
0065 ActionMap::const_iterator ib(map_.begin()), ie(map_.end());
0066 for (; ib != ie; ++ib) {
0067 std::cerr << ib->first << ',' << ib->second << '\n';
0068 }
0069 std::cerr << std::endl;
0070 }
0071 }
0072
0073 ExceptionToActionTable::~ExceptionToActionTable() {}
0074
0075 void ExceptionToActionTable::add(std::string const& category, exception_actions::ActionCodes code) {
0076 map_[category] = code;
0077 }
0078
0079 exception_actions::ActionCodes ExceptionToActionTable::find(std::string const& category) const {
0080 ActionMap::const_iterator i(map_.find(category));
0081 return i != map_.end() ? i->second : exception_actions::Rethrow;
0082 }
0083
0084 }