Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include "DataFormats/Common/interface/ConvertHandle.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "DataFormats/Common/interface/FunctorHandleExceptionFactory.h"

namespace edm {
  namespace handleimpl {
    static std::shared_ptr<HandleExceptionFactory const> const s_invalidRefFactory =
        makeHandleExceptionFactory([]() -> std::shared_ptr<cms::Exception> {
          std::shared_ptr<cms::Exception> whyFailed =
              std::make_shared<edm::Exception>(errors::InvalidReference, "NullPointer");
          *whyFailed << "Handle has null pointer to data product";
          return whyFailed;
        });

    std::shared_ptr<HandleExceptionFactory const> makeInvalidReferenceException() { return s_invalidRefFactory; }

    void throwConvertTypeError(std::type_info const& expected, std::type_info const& actual) {
      throw Exception(errors::LogicError, "TypeMismatch")
          << "edm::BasicHandle contains a product of type " << actual.name() << ".\n"
          << "A type of " << expected.name() << "was expected.";
    }
  }  // namespace handleimpl
}  // namespace edm