File indexing completed on 2024-04-06 12:12:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023
0024 #include "FWCore/Framework/interface/MakerMacros.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026
0027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0028
0029 #include "FWCore/Framework/test/stubs/TestFailuresAnalyzer.h"
0030
0031 #include "FWCore/Utilities/interface/Exception.h"
0032 #include "FWCore/Utilities/interface/EDMException.h"
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 enum { kConstructor, kBeginOfJob, kEvent, kEndOfJob, kBeginOfJobBadXML, kEventCorruption };
0046
0047
0048
0049 TestFailuresAnalyzer::TestFailuresAnalyzer(const edm::ParameterSet& iConfig)
0050 : whichFailure_(iConfig.getParameter<int>("whichFailure")),
0051 eventToThrow_(iConfig.getUntrackedParameter<unsigned long long>("eventToThrow", 2U)) {
0052
0053 if (whichFailure_ == kConstructor) {
0054 throw cms::Exception("Test") << " constructor";
0055 }
0056 }
0057
0058
0059
0060
0061
0062
0063 void TestFailuresAnalyzer::beginJob() {
0064 if (whichFailure_ == kBeginOfJob) {
0065 throw cms::Exception("Test") << " beginJob";
0066 }
0067 if (whichFailure_ == kBeginOfJobBadXML) {
0068 throw cms::Exception("Test") << " beginJob with <BAD> >XML<";
0069 }
0070 }
0071
0072 void TestFailuresAnalyzer::endJob() {
0073 if (whichFailure_ == kEndOfJob) {
0074 throw cms::Exception("Test") << " endJob";
0075 }
0076 }
0077
0078 void TestFailuresAnalyzer::analyze(edm::StreamID,
0079 const edm::Event& e ,
0080 const edm::EventSetup& ) const {
0081 if (whichFailure_ == kEvent) {
0082 throw cms::Exception("Test") << " event";
0083 }
0084 if (whichFailure_ == kEventCorruption && eventToThrow_ == e.eventAuxiliary().event()) {
0085 throw edm::Exception(edm::errors::EventCorruption, "testing exception handling");
0086 }
0087 }
0088
0089
0090 DEFINE_FWK_MODULE(TestFailuresAnalyzer);