diff --git a/src/libraries/JANA/Omni/JComponent.h b/src/libraries/JANA/Omni/JComponent.h index 18cdcbce6..11439c893 100644 --- a/src/libraries/JANA/Omni/JComponent.h +++ b/src/libraries/JANA/Omni/JComponent.h @@ -91,6 +91,16 @@ class JComponent::Service : public JComponent::ServiceBase { } ServiceT& operator()() { + if (m_data == nullptr) { + throw JException("Attempted to access a Service which hasn't been attached to this Component yet!"); + } + return *m_data; + } + + ServiceT& operator->() { + if (m_data == nullptr) { + throw JException("Attempted to access a Service which hasn't been attached to this Component yet!"); + } return *m_data; }