Skip to content

Commit

Permalink
Ensure that pex_exceptions is imported
Browse files Browse the repository at this point in the history
Without this, pex exceptions raised inside the C++ layer
do not reliably get converted to the correct Python exception
type.
  • Loading branch information
timj committed Apr 2, 2019
1 parent 47df011 commit 0391992
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import warnings
from collections.abc import Mapping, KeysView

# Ensure that C++ exceptions are properly translated to Python
import lsst.pex.exceptions # noqa: F401
from lsst.utils import continueClass

from .propertySet import PropertySet
Expand Down Expand Up @@ -143,7 +145,7 @@ def _propertyContainerElementTypeName(container, name):
"""Return name of the type of a particular element"""
try:
t = container.typeOf(name)
except (LookupError, RuntimeError) as e:
except LookupError as e:
# KeyError is more commonly expected when asking for an element
# from a mapping.
raise KeyError(str(e))
Expand Down

0 comments on commit 0391992

Please sign in to comment.