Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-16 00:05:37

0001 #include "FWCore/Framework/interface/resolveMaker.h"
0002 
0003 namespace edm::detail {
0004   void annotateResolverMakerExceptionAndRethrow(cms::Exception& except,
0005                                                 std::string const& modtype,
0006                                                 ModuleTypeResolverBase const* resolver) {
0007     if (not resolver) {
0008       throw except;
0009     }
0010     //if needed, create list of alternative types that were tried
0011     std::string alternativeTypes;
0012     auto index = resolver->kInitialIndex;
0013     auto newType = modtype;
0014     int tries = 0;
0015     do {
0016       ++tries;
0017       if (not alternativeTypes.empty()) {
0018         alternativeTypes.append(", ");
0019       }
0020       auto [ttype, tindex] = resolver->resolveType(std::move(newType), index);
0021       newType = std::move(ttype);
0022       index = tindex;
0023       alternativeTypes.append(newType);
0024     } while (index != resolver->kLastIndex);
0025     if (tries == 1 and alternativeTypes == modtype) {
0026       throw except;
0027     }
0028     alternativeTypes.insert(0, "These alternative types were tried: ");
0029     except.addAdditionalInfo(alternativeTypes);
0030     throw except;
0031   }
0032 }  // namespace edm::detail