Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Service type in an exception message from ServiceRegistry #39636

Merged
merged 2 commits into from Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions FWCore/ServiceRegistry/interface/ServiceRegistry.h
Expand Up @@ -23,6 +23,7 @@
#include "FWCore/ServiceRegistry/interface/ServiceLegacy.h"
#include "FWCore/ServiceRegistry/interface/ServiceToken.h"
#include "FWCore/ServiceRegistry/interface/ServicesManager.h"
#include "FWCore/Utilities/interface/TypeDemangler.h"

// system include files
#include <vector>
Expand Down Expand Up @@ -61,19 +62,21 @@ namespace edm {
template <typename T>
T& get() const {
if (nullptr == manager_.get()) {
auto demangled = typeDemangle(typeid(T).name());
Exception::throwThis(errors::NotFound,
"Service"
" no ServiceRegistry has been set for this thread");
"No ServiceRegistry has been set for this thread. Tried to get a Service ",
demangled.c_str());
}
return manager_->template get<T>();
}

template <typename T>
bool isAvailable() const {
if (nullptr == manager_.get()) {
auto demangled = typeDemangle(typeid(T).name());
Exception::throwThis(errors::NotFound,
"Service"
" no ServiceRegistry has been set for this thread");
"No ServiceRegistry has been set for this thread. Tried to ask availability of a Service ",
demangled.c_str());
}
return manager_->template isAvailable<T>();
}
Expand Down
4 changes: 3 additions & 1 deletion FWCore/ServiceRegistry/interface/ServicesManager.h
Expand Up @@ -24,6 +24,7 @@
#include "FWCore/ServiceRegistry/interface/ServiceMakerBase.h"
#include "FWCore/ServiceRegistry/interface/ServiceWrapper.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/TypeDemangler.h"
#include "FWCore/Utilities/interface/TypeIDBase.h"
#include "FWCore/Utilities/interface/propagate_const.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
Expand Down Expand Up @@ -80,9 +81,10 @@ namespace edm {
//do on demand building of the service
if (nullptr == type2Maker_.get() ||
type2Maker_->end() == (itFoundMaker = type2Maker_->find(TypeIDBase(typeid(T))))) {
auto demangled = typeDemangle(typeid(T).name());
Exception::throwThis(errors::NotFound,
"Service Request unable to find requested service with compiler type name '",
typeid(T).name(),
demangled.c_str(),
"'.\n");
} else {
const_cast<ServicesManager&>(*this).createServiceFor(itFoundMaker->second);
Expand Down