mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-22 16:39:29 +00:00
exception handler tweaks (fixes #284)
This commit is contained in:
parent
d46b6eee5a
commit
6969e7c1ba
@ -104,18 +104,18 @@ PYBIND11_NOINLINE inline handle get_type_handle(const std::type_info &tp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline std::string error_string() {
|
PYBIND11_NOINLINE inline std::string error_string() {
|
||||||
std::string errorString;
|
PyObject *type, *value, *traceback;
|
||||||
PyThreadState *tstate = PyThreadState_GET();
|
PyErr_Fetch(&type, &value, &traceback);
|
||||||
if (tstate == nullptr)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
if (tstate->curexc_type) {
|
std::string errorString;
|
||||||
errorString += (std::string) handle(tstate->curexc_type).str();
|
if (type) {
|
||||||
|
errorString += (std::string) handle(type).str();
|
||||||
errorString += ": ";
|
errorString += ": ";
|
||||||
}
|
}
|
||||||
if (tstate->curexc_value)
|
if (value)
|
||||||
errorString += (std::string) handle(tstate->curexc_value).str();
|
errorString += (std::string) handle(value).str();
|
||||||
|
|
||||||
|
PyErr_Restore(type, value, traceback);
|
||||||
return errorString;
|
return errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user