The pyo3_runtime.PanicException
inherits from Python's BaseException
, so using BaseException
in the try:except
block successfully catches the panic. It's quite a broad sweep but will do in a pinch.
See another SO q&a here
See the pyo3 docs here