Skip to content

Commit 33c724d

Browse files
authored
Merge pull request #5 from lauralindzey/more_informative_exceptions
Print out more of the traceback when throwing pyMOOSException
2 parents 1c9f83c + a7724b8 commit 33c724d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/pyMOOS.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ class AsyncCommsWrapper : public MOOS::MOOSAsyncCommClient {
100100
bResult = py::bool_(result);
101101
} catch (const py::error_already_set& e) {
102102
PyGILState_Release(gstate);
103-
throw pyMOOSException(
104-
"OnConnect:: caught an exception thrown in python callback");
103+
std::string err_msg = "OnConnect:: caught an exception thrown in python callback:\n";
104+
err_msg.append(e.what());
105+
throw pyMOOSException(err_msg.c_str());
105106
}
106107

107108
PyGILState_Release(gstate);
@@ -133,8 +134,9 @@ class AsyncCommsWrapper : public MOOS::MOOSAsyncCommClient {
133134
}
134135
} catch (const py::error_already_set& e) {
135136
PyGILState_Release(gstate);
136-
throw pyMOOSException(
137-
"OnMail:: caught an exception thrown in python callback");
137+
std::string err_msg = "OnMail:: caught an exception thrown in python callback:\n";
138+
err_msg.append(e.what());
139+
throw pyMOOSException(err_msg.c_str());
138140
}
139141

140142
PyGILState_Release(gstate);
@@ -165,8 +167,9 @@ class AsyncCommsWrapper : public MOOS::MOOSAsyncCommClient {
165167
bResult = py::bool_(result);
166168
} catch (const py::error_already_set& e) {
167169
PyGILState_Release(gstate);
168-
throw pyMOOSException(
169-
"ActiveQueue:: caught an exception thrown in python callback");
170+
std::string err_msg = "ActiveQueue:: caught an exception thrown in python callback:\n";
171+
err_msg.append(e.what());
172+
throw pyMOOSException(err_msg.c_str());
170173
}
171174

172175
PyGILState_Release(gstate);

0 commit comments

Comments
 (0)