.. index:: py::builtins::BaseException::what .. _doxycast_pypp_classpy_1_1builtins_1_1BaseException_1a700948a8a5902714ef166a9cf4517d4c: .. _py-builtins-BaseException-what: *py::builtins::BaseException::*\ what ===================================== .. code-block:: cpp virtual const char* what() const noexcept override; // 1 Returns the explanatory string. Return value ------------ The explanatory string. Example ------- .. code-block:: cpp #include int main() { try { py::raise(py::BaseException("example exception")); } catch (py::BaseException& exception) { py::print("exception handled successfully:", exception.what()); } } **Output**: .. code-block:: text exception handled successfully: example exception