Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:00

0001 #include "FWCore/PythonParameterSet/interface/PyBind11Wrapper.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "FWCore/Utilities/interface/EDMException.h"
0004 namespace edm {
0005 
0006   void pythonToCppException(const std::string& iType, const std::string& error) {
0007     auto colon = error.find(':');
0008     if (colon != std::string::npos) {
0009       if (error.substr(0, colon) == "EDMException") {
0010         auto errorNameStart = error.find('{');
0011         auto errorNameEnd = error.find('}');
0012         if (errorNameStart != std::string::npos and errorNameEnd != std::string::npos) {
0013           auto errorName = error.substr(errorNameStart + 1, errorNameEnd - errorNameStart - 1);
0014           if ("Configuration" == errorName) {
0015             auto newLine = error.find('\n', errorNameEnd + 1);
0016             if (newLine == std::string::npos) {
0017               newLine = errorNameEnd + 1;
0018             }
0019             throw edm::Exception(edm::errors::Configuration) << error.substr(newLine + 1, std::string::npos);
0020           } else if ("UnavailableAccelerator" == errorName) {
0021             auto newLine = error.find('\n', errorNameEnd + 1);
0022             if (newLine == std::string::npos) {
0023               newLine = errorNameEnd + 1;
0024             }
0025             throw edm::Exception(edm::errors::UnavailableAccelerator) << error.substr(newLine + 1, std::string::npos);
0026           }
0027         }
0028       }
0029     }
0030     throw cms::Exception(iType) << " unknown python problem occurred.\n" << error << std::endl;
0031   }
0032 }  // namespace edm