diff --git a/include/lsst/afw/detection/Psf.h b/include/lsst/afw/detection/Psf.h index e5b5a6179..6e1dd25be 100644 --- a/include/lsst/afw/detection/Psf.h +++ b/include/lsst/afw/detection/Psf.h @@ -28,6 +28,7 @@ #include +#include "lsst/pex/exceptions.h" #include "lsst/utils/CacheFwd.h" #include "lsst/afw/geom/ellipses/Quadrupole.h" #include "lsst/afw/math/Kernel.h" @@ -45,6 +46,11 @@ struct PsfCacheKey; } // namespace detail +/** + * An exception thrown when we have an invalid PSF. + */ +LSST_EXCEPTION_TYPE(InvalidPsfError, lsst::pex::exceptions::InvalidParameterError, lsst::afw::detection::InvalidPsfError) + /** * A polymorphic base class for representing an image's Point Spread Function * diff --git a/python/lsst/afw/detection/_psf.cc b/python/lsst/afw/detection/_psf.cc index 5ddb43eb6..0fda6203b 100644 --- a/python/lsst/afw/detection/_psf.cc +++ b/python/lsst/afw/detection/_psf.cc @@ -28,6 +28,8 @@ #include "lsst/utils/python.h" #include "lsst/utils/python/PySharedPtr.h" +#include "lsst/pex/exceptions/Runtime.h" +#include "lsst/pex/exceptions/python/Exception.h" #include "lsst/geom/Point.h" #include "lsst/afw/image/Color.h" #include "lsst/afw/table/io/python.h" // for addPersistableMethods @@ -51,6 +53,9 @@ void wrapPsf(utils::python::WrapperCollection& wrappers) { wrappers.addSignatureDependency("lsst.afw.image"); wrappers.addSignatureDependency("lsst.afw.fits"); + wrappers.wrapException("InvalidPsfError", + "InvalidParameterError"); + auto clsPsf = wrappers.wrapType( py::class_, typehandling::Storable, PsfTrampoline<>>( wrappers.module, "Psf"