CMS 3D CMS Logo

PyBind11Wrapper.cc
Go to the documentation of this file.
4 namespace edm {
5 
6  void pythonToCppException(const std::string& iType, const std::string& error) {
7  auto colon = error.find(':');
8  if (colon != std::string::npos) {
9  if (error.substr(0, colon) == "EDMException") {
10  auto errorNameStart = error.find('{');
11  auto errorNameEnd = error.find('}');
12  if (errorNameStart != std::string::npos and errorNameEnd != std::string::npos) {
13  auto errorName = error.substr(errorNameStart + 1, errorNameEnd - errorNameStart - 1);
14  if ("Configuration" == errorName) {
15  auto newLine = error.find('\n', errorNameEnd + 1);
16  if (newLine == std::string::npos) {
17  newLine = errorNameEnd + 1;
18  }
19  throw edm::Exception(edm::errors::Configuration) << error.substr(newLine + 1, std::string::npos);
20  } else if ("UnavailableAccelerator" == errorName) {
21  auto newLine = error.find('\n', errorNameEnd + 1);
22  if (newLine == std::string::npos) {
23  newLine = errorNameEnd + 1;
24  }
25  throw edm::Exception(edm::errors::UnavailableAccelerator) << error.substr(newLine + 1, std::string::npos);
26  }
27  }
28  }
29  }
30  throw cms::Exception(iType) << " unknown python problem occurred.\n" << error << std::endl;
31  }
32 } // namespace edm
void pythonToCppException(const std::string &iType, const std::string &error)
HLT enums.