Skip to content

Commit

Permalink
PyPanda: fix exception handling in _run_and_catch
Browse files Browse the repository at this point in the history
Previously after an exception had been raised we would return None in all callbacks and trigger additional type errors.
  • Loading branch information
Andrew Fasano committed Jun 13, 2024
1 parent debd328 commit 236c1a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion panda/python/core/pandare/panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2728,7 +2728,11 @@ def decorator(fun):
return_from_exception = 0

def _run_and_catch(*args, **kwargs): # Run function but if it raises an exception, stop panda and raise it
if not hasattr(self, "exit_exception"):
if hasattr(self, "exit_exception"):
# An exception has been raised previously - do not even run the function. But we need to match the expected
# return type or we'll raise more errors.
return self.ffi.cast(return_type, 0)
else:
try:
r = fun(*args, **kwargs)
#print(pandatype, type(r)) # XXX Can we use pandatype to determine requried return and assert if incorrect
Expand Down

0 comments on commit 236c1a8

Please sign in to comment.