I am making code in python using pybind11.
For example, I have test1.cpp, test_pybind.cpp and example.py
heaan_pybind.cpp
namespace py=pybind11;
PYBIND11_MODULE(test, m)
{
py::class_<test1>(m, "test1")
.def("fn", ...)
}
And in example.py, I want to control the exception like below.
import test
while True:
try:
test.test1.fn(...)
except ???:
print("exception error.")
How can I catch the error or exception from test.cpp in example.py ?