Skip to content

Commit 35ea795

Browse files
committed
Add reason to exception message if module label in ESInputTag does not match
1 parent 1ccd187 commit 35ea795

18 files changed

+211
-284
lines changed

FWCore/Framework/interface/ESRecordsToProductResolverIndices.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_ESRecordsToProductResolverIndices_h
23
#define FWCore_Framework_ESRecordsToProductResolverIndices_h
3-
// -*- C++ -*-
44
//
55
// Package: Framework
66
// Class : ESRecordsToProductResolverIndices
77
//
8-
/**\class ESRecordsToProductResolverIndices ESRecordsToProductResolverIndices.h FWCore/Framework/interface/ESRecordsToProductResolverIndices.h
8+
/**\class edm::eventsetup::ESRecordsToProductResolverIndices
99
1010
Description: Key used to identify data within a EventSetupRecord
1111
@@ -19,7 +19,6 @@
1919
//
2020

2121
// system include files
22-
#include <limits>
2322
#include <vector>
2423

2524
// user include files
@@ -37,17 +36,14 @@ namespace edm::eventsetup {
3736
ESRecordsToProductResolverIndices(std::vector<EventSetupRecordKey> iRecords);
3837

3938
// ---------- const member functions ---------------------
40-
///If the index is not found, returns missingResolverIndex()
39+
///If the index is not found, returns ESResolverIndex::noResolverConfigured()
4140
ESResolverIndex indexInRecord(EventSetupRecordKey const& iRK, DataKey const& iDK) const noexcept;
4241

4342
ComponentDescription const* component(EventSetupRecordKey const& iRK, DataKey const& iDK) const noexcept;
4443

4544
///Returns ESTagGetter for all products matching the type iTT for record iRK
4645
ESTagGetter makeTagGetter(EventSetupRecordKey const& iRK, TypeTag const& iTT) const;
4746

48-
static constexpr ESResolverIndex missingResolverIndex() noexcept {
49-
return ESResolverIndex{std::numeric_limits<int>::max()};
50-
}
5147
static constexpr ESRecordIndex missingRecordIndex() noexcept {
5248
return ESRecordIndex{ESRecordIndex::invalidValue()};
5349
}

FWCore/Framework/interface/EventSetupRecord.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_EventSetupRecord_h
23
#define FWCore_Framework_EventSetupRecord_h
3-
// -*- C++ -*-
44
//
55
// Package: Framework
66
// Class : EventSetupRecord
@@ -41,6 +41,7 @@
4141
// user include files
4242
#include "FWCore/Framework/interface/FunctorESHandleExceptionFactory.h"
4343
#include "FWCore/Framework/interface/DataKey.h"
44+
#include "FWCore/Framework/interface/HCTypeTag.h"
4445
#include "FWCore/Framework/interface/NoProductResolverException.h"
4546
#include "FWCore/Framework/interface/ValidityInterval.h"
4647
#include "FWCore/Framework/interface/EventSetupRecordImpl.h"
@@ -163,8 +164,13 @@ namespace edm {
163164
}
164165

165166
auto resolverIndex = getTokenIndices_[iToken.index().value()];
166-
if UNLIKELY (resolverIndex.value() == std::numeric_limits<int>::max()) {
167-
return noResolverHandle<H>(iToken);
167+
168+
if UNLIKELY (resolverIndex == ESResolverIndex::moduleLabelDoesNotMatch()) {
169+
return noResolverHandle<H>(iToken, true);
170+
}
171+
172+
if UNLIKELY (resolverIndex == ESResolverIndex::noResolverConfigured()) {
173+
return noResolverHandle<H>(iToken, false);
168174
}
169175

170176
T const* value = nullptr;
@@ -204,11 +210,11 @@ namespace edm {
204210
}
205211

206212
template <template <typename> typename H, typename T, typename R>
207-
H<T> noResolverHandle(ESGetToken<T, R> const& iToken) const {
213+
H<T> noResolverHandle(ESGetToken<T, R> const& iToken, bool moduleLabelDoesNotMatch) const {
208214
auto const key = this->key();
209215
auto productLabel = iToken.productLabel();
210-
return H<T>{makeESHandleExceptionFactory([key, productLabel] {
211-
NoProductResolverException<T> ex(key, DataKey{DataKey::makeTypeTag<T>(), productLabel});
216+
return H<T>{makeESHandleExceptionFactory([key, productLabel, moduleLabelDoesNotMatch] {
217+
NoProductResolverException ex(key, heterocontainer::className<T>(), productLabel, moduleLabelDoesNotMatch);
212218
return std::make_exception_ptr(ex);
213219
})};
214220
}

FWCore/Framework/interface/EventSetupRecordImpl.h

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_EventSetupRecordImpl_h
23
#define FWCore_Framework_EventSetupRecordImpl_h
3-
// -*- C++ -*-
44
//
55
// Package: Framework
66
// Class : EventSetupRecordImpl
@@ -37,7 +37,6 @@ through the 'validityInterval' method.
3737
// user include files
3838
#include "FWCore/Framework/interface/FunctorESHandleExceptionFactory.h"
3939
#include "FWCore/Framework/interface/DataKey.h"
40-
#include "FWCore/Framework/interface/NoProductResolverException.h"
4140
#include "FWCore/Framework/interface/ValidityInterval.h"
4241
#include "FWCore/Framework/interface/EventSetupRecordKey.h"
4342
#include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
@@ -46,8 +45,6 @@ through the 'validityInterval' method.
4645
#include "FWCore/Utilities/interface/ESIndices.h"
4746

4847
// system include files
49-
#include <exception>
50-
#include <limits>
5148
#include <memory>
5249
#include <vector>
5350
#include <atomic>
@@ -166,23 +163,9 @@ namespace edm {
166163
ComponentDescription const*& oDesc,
167164
std::shared_ptr<ESHandleExceptionFactory>& whyFailedFactory) const {
168165
DataKey const* dataKey = nullptr;
169-
if (iResolverIndex.value() == std::numeric_limits<int>::max()) {
170-
whyFailedFactory = makeESHandleExceptionFactory([this] {
171-
NoProductResolverException<DataT> ex(this->key(), {});
172-
return std::make_exception_ptr(ex);
173-
});
174-
iData = nullptr;
175-
return;
176-
}
177166
assert(iResolverIndex.value() > -1 and
178167
iResolverIndex.value() < static_cast<ESResolverIndex::Value_t>(keysForProxies_.size()));
179168
void const* pValue = this->getFromResolverAfterPrefetch(iResolverIndex, iTransientAccessOnly, oDesc, dataKey);
180-
if (nullptr == pValue) {
181-
whyFailedFactory = makeESHandleExceptionFactory([this, dataKey] {
182-
NoProductResolverException<DataT> ex(this->key(), *dataKey);
183-
return std::make_exception_ptr(ex);
184-
});
185-
}
186169
iData = reinterpret_cast<DataT const*>(pValue);
187170
}
188171

FWCore/Framework/interface/NoDataException.h

Lines changed: 0 additions & 125 deletions
This file was deleted.
Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,35 @@
1+
// -*- C++ -*-
12
#ifndef FWCore_Framework_NoProductResolverException_h
23
#define FWCore_Framework_NoProductResolverException_h
3-
// -*- C++ -*-
44
//
55
// Package: Framework
66
// Module: NoProductResolverException
77
//
8-
/**\class NoProductResolverException NoProductResolverException.h FWCore/Framework/interface/NoProductResolverException.h
8+
/**\class edm::eventsetup::NoProductResolverException
99
1010
Description: An exception that is thrown whenever resolver was not available
11-
in the EventSetup, it is subset of NoDataException, see more details
12-
in that class
13-
11+
in the EventSetup
1412
*/
1513
//
1614
// Author: Valentine Kouznetsov
1715
// Created: Wed Apr 23 10:58:26 EDT 2003
1816
//
19-
//
2017

21-
// system include files
22-
23-
// user include files
24-
#include "FWCore/Framework/interface/NoDataException.h"
2518
#include "FWCore/Framework/interface/EventSetupRecordKey.h"
19+
#include "FWCore/Utilities/interface/Exception.h"
2620

27-
// forward declarations
2821
namespace edm {
2922
namespace eventsetup {
30-
template <class T>
31-
class NoProductResolverException : public NoDataException<T> {
32-
// ---------- friend classes and functions ---------------
3323

24+
class NoProductResolverException : public cms::Exception {
3425
public:
35-
// ---------- constants, enums and typedefs --------------
36-
37-
// ---------- Constructors and destructor ----------------
38-
NoProductResolverException(const EventSetupRecordKey& iKey, const DataKey& iDataKey)
39-
: NoDataException<T>(iKey, iDataKey, "NoProductResolverException", NoDataExceptionBase::noProviderMessage()) {
40-
}
41-
42-
// ---------- member functions ---------------------------
43-
44-
private:
45-
// ---------- const member functions ---------------------
46-
47-
// ---------- static member functions --------------------
48-
49-
// ---------- Constructors and destructor ----------------
50-
//NoProductResolverException(const NoProductResolverException&) ; //allow default
51-
52-
//const NoProductResolverException& operator=(const NoProductResolverException&); // allow default
53-
54-
// ---------- data members -------------------------------
26+
NoProductResolverException(const EventSetupRecordKey&,
27+
const char* iClassName,
28+
const char* productLabel,
29+
bool moduleLabelDoesNotMatch);
5530
};
31+
5632
} // namespace eventsetup
5733
} // namespace edm
58-
// inline function definitions
5934

6035
#endif

FWCore/Framework/src/EDConsumerBase.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ void EDConsumerBase::updateLookup(eventsetup::ESRecordsToProductResolverIndices
153153
unsigned int index = 0;
154154
for (auto it = m_esTokenInfo.begin<kESLookupInfo>(); it != m_esTokenInfo.end<kESLookupInfo>(); ++it, ++index) {
155155
auto indexInRecord = iPI.indexInRecord(it->m_record, it->m_key);
156-
if (indexInRecord != eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex()) {
156+
if (indexInRecord != ESResolverIndex::noResolverConfigured()) {
157157
const char* componentName = &(m_tokenLabels[it->m_startOfComponentName]);
158158
if (*componentName) {
159159
auto component = iPI.component(it->m_record, it->m_key);
160160
if (component->label_.empty()) {
161161
if (component->type_ != componentName) {
162-
indexInRecord = eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex();
162+
indexInRecord = ESResolverIndex::moduleLabelDoesNotMatch();
163163
}
164164
} else if (component->label_ != componentName) {
165-
indexInRecord = eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex();
165+
indexInRecord = ESResolverIndex::moduleLabelDoesNotMatch();
166166
}
167167
}
168168
}

FWCore/Framework/src/ESProducer.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "FWCore/Framework/interface/ESProducer.h"
1414
#include "FWCore/Framework/interface/ESRecordsToProductResolverIndices.h"
1515
#include "FWCore/Framework/interface/SharedResourcesRegistry.h"
16+
#include "FWCore/Utilities/interface/ESIndices.h"
1617

1718
namespace edm {
1819

@@ -51,27 +52,28 @@ namespace edm {
5152
records.emplace_back(eventsetup::ESRecordsToProductResolverIndices::missingRecordIndex());
5253
}
5354
chooser->setTagGetter(std::move(tagGetter));
54-
items.push_back(eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex());
55+
// This value will get overwritten before being used
56+
items.push_back(ESResolverIndex::noResolverConfigured());
5557
} else {
5658
auto index = iResolverToIndices.indexInRecord(resolverInfo.recordKey_, resolverInfo.productKey_);
57-
if (index != eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex()) {
59+
if (index != ESResolverIndex::noResolverConfigured()) {
5860
if (not resolverInfo.moduleLabel_.empty()) {
5961
auto component = iResolverToIndices.component(resolverInfo.recordKey_, resolverInfo.productKey_);
6062
if (nullptr == component) {
61-
index = eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex();
63+
index = ESResolverIndex::moduleLabelDoesNotMatch();
6264
} else {
6365
if (component->label_.empty()) {
6466
if (component->type_ != resolverInfo.moduleLabel_) {
65-
index = eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex();
67+
index = ESResolverIndex::moduleLabelDoesNotMatch();
6668
}
6769
} else if (component->label_ != resolverInfo.moduleLabel_) {
68-
index = eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex();
70+
index = ESResolverIndex::moduleLabelDoesNotMatch();
6971
}
7072
}
7173
}
7274
}
7375
items.push_back(index);
74-
if (index != eventsetup::ESRecordsToProductResolverIndices::missingResolverIndex()) {
76+
if (index != ESResolverIndex::noResolverConfigured() && index != ESResolverIndex::moduleLabelDoesNotMatch()) {
7577
records.push_back(iResolverToIndices.recordIndexFor(resolverInfo.recordKey_));
7678
} else {
7779
//The record is not actually missing but the resolver is

0 commit comments

Comments
 (0)