@@ -133,7 +133,11 @@ std::unique_ptr<ROOTFrameData> ROOTReader::readEntry(ROOTReader::CategoryInfo& c
133
133
if (!collsToRead.empty () && std::ranges::find (collsToRead, catInfo.storedClasses [i].name ) == collsToRead.end ()) {
134
134
continue ;
135
135
}
136
- buffers.emplace (catInfo.storedClasses [i].name , getCollectionBuffers (catInfo, i, reloadBranches, localEntry));
136
+ auto collBuffers = getCollectionBuffers (catInfo, i, reloadBranches, localEntry);
137
+ if (!collBuffers) {
138
+ return nullptr ;
139
+ }
140
+ buffers.emplace (catInfo.storedClasses [i].name , collBuffers.value ());
137
141
}
138
142
139
143
auto parameters = readEntryParameters (catInfo, reloadBranches, localEntry);
@@ -142,17 +146,22 @@ std::unique_ptr<ROOTFrameData> ROOTReader::readEntry(ROOTReader::CategoryInfo& c
142
146
return std::make_unique<ROOTFrameData>(std::move (buffers), catInfo.table , std::move (parameters));
143
147
}
144
148
145
- podio::CollectionReadBuffers ROOTReader::getCollectionBuffers (ROOTReader::CategoryInfo& catInfo, size_t iColl,
146
- bool reloadBranches, unsigned int localEntry) {
149
+ std::optional<podio::CollectionReadBuffers> ROOTReader::getCollectionBuffers (ROOTReader::CategoryInfo& catInfo,
150
+ size_t iColl, bool reloadBranches,
151
+ unsigned int localEntry) {
147
152
const auto & name = catInfo.storedClasses [iColl].name ;
148
153
const auto & [collType, isSubsetColl, schemaVersion, index] = catInfo.storedClasses [iColl].info ;
149
154
auto & branches = catInfo.branches [index];
150
155
151
156
const auto & bufferFactory = podio::CollectionBufferFactory::instance ();
152
157
auto maybeBuffers = bufferFactory.createBuffers (collType, schemaVersion, isSubsetColl);
153
158
154
- // TODO: Error handling of empty optional
155
- auto collBuffers = maybeBuffers.value_or (podio::CollectionReadBuffers{});
159
+ if (!maybeBuffers) {
160
+ std::cerr << " WARNING: Buffers couldn't be created for collection " << name << " of type " << collType
161
+ << " and schema version " << schemaVersion << std::endl;
162
+ return std::nullopt ;
163
+ }
164
+ auto collBuffers = maybeBuffers.value ();
156
165
157
166
if (reloadBranches) {
158
167
root_utils::resetBranches (catInfo.chain .get (), branches, name);
0 commit comments