Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:11

0001 #include "FWCore/Framework/interface/ExceptionHelpers.h"
0002 
0003 #include "FWCore/MessageLogger/interface/ExceptionMessages.h"
0004 #include "FWCore/MessageLogger/interface/JobReport.h"
0005 #include "FWCore/ServiceRegistry/interface/Service.h"
0006 
0007 #include <cstring>
0008 
0009 namespace edm {
0010 
0011   void addContextAndPrintException(char const* context, cms::Exception& ex, bool disablePrint) {
0012     if (context != nullptr && strlen(context) != 0U) {
0013       ex.addContext(context);
0014     }
0015     if (!disablePrint) {
0016       Service<JobReport> jobReportSvc;
0017       if (jobReportSvc.isAvailable()) {
0018         JobReport* jobRep = jobReportSvc.operator->();
0019         edm::printCmsException(ex, jobRep, ex.returnCode());
0020       } else {
0021         edm::printCmsException(ex);
0022       }
0023       ex.setAlreadyPrinted();
0024     }
0025   }
0026 }  // namespace edm