Lines Matching refs:exception
2 tests/test_custom-exceptions.cpp -- exception translation
12 // A type that should be raised as an exception in Python
13 class MyException : public std::exception {
21 // A type that should be translated to a standard Python exception
22 class MyException2 : public std::exception {
30 // A type that is not derived from std::exception (and is thus unknown)
40 // and delegated to its exception translator
41 class MyException4 : public std::exception {
70 throw std::runtime_error("This exception was intentionally thrown.");
73 // make a new custom exception and use it as a translation target
74 static py::exception<MyException> ex(m, "MyException");
91 // Translate this exception to a standard RuntimeError
98 // translator for MyException by throwing a new exception
107 // A simple exception translation:
113 m.def("throws2", []() { throw MyException2("this error should go to a standard Python exception"); });
116 m.def("throws5", []() { throw MyException5("this is a helper-defined translated exception"); });