From a25a25fc4529523187ebbfb54238749faa6e9375 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Tue, 7 May 2024 09:59:22 -0700 Subject: [PATCH] Add InvalidPsfError exception. --- include/lsst/afw/detection/Psf.h | 6 ++++++ python/lsst/afw/detection/_psf.cc | 6 ++++++ 2 files changed, 12 insertions(+) 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..7c9d96546 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,10 @@ void wrapPsf(utils::python::WrapperCollection& wrappers) { wrappers.addSignatureDependency("lsst.afw.image"); wrappers.addSignatureDependency("lsst.afw.fits"); + auto cls = wrappers.wrapException("InvalidPsfError", + "InvalidParameterError"); + cls.def(py::init()); + auto clsPsf = wrappers.wrapType( py::class_, typehandling::Storable, PsfTrampoline<>>( wrappers.module, "Psf"