Coverage for python/lsst/pex/exceptions/wrappers.py : 81%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of pex_exceptions. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (https://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>.
"DomainError", "InvalidParameterError", "LengthError", "OutOfRangeError", "RuntimeError", "RangeError", "OverflowError", "UnderflowError", "NotFoundError", "IoError", "TypeError", "translate", "declare"]
"""A Python decorator that adds a Python exception wrapper to the registry that maps C++ Exceptions to their Python wrapper classes. """
"""A metaclass for custom exception wrappers, which adds lookup of class attributes by delegating to the Swig-generated wrapper. """
return getattr(cls.WrappedClass, name)
"""The base class for Python-wrapped LSST C++ exceptions. """
# wrappers.py is an implementation detail, not a public namespace, so we pretend this is defined # in the package for pretty-printing purposes
if isinstance(arg, exceptions.Exception): cpp = arg message = cpp.what() else: message = arg cpp = self.WrappedClass(message, *args, **kwds) super(Exception, self).__init__(message) self.cpp = cpp
return getattr(self.cpp, name)
return "%s('%s')" % (type(self).__name__, self.cpp.what())
return self.cpp.asString()
"""Translate a C++ Exception instance to Python and return it.""" PyType = registry.get(type(cpp), None) if PyType is None: warnings.warn("Could not find appropriate Python type for C++ Exception") PyType = Exception return PyType(cpp)
"""Declare a new exception.""" dict(WrappedClass=wrapped_class)))) |