Skip to content

Commit

Permalink
Catch errors from callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Jun 24, 2024
1 parent 594f0ff commit 1eb82ff
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions wrapper/Convert/SireOpenMM/pyqm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,44 @@ PyQMCallback::call(

if (this->is_method)
{
return bp::call_method<boost::tuple<double, QVector<QVector<double>>, QVector<QVector<double>>>>(
this->py_object.ptr(),
this->name.toStdString().c_str(),
numbers_qm,
charges_mm,
xyz_qm,
xyz_mm
);
try
{
return bp::call_method<boost::tuple<double, QVector<QVector<double>>, QVector<QVector<double>>>>(
this->py_object.ptr(),
this->name.toStdString().c_str(),
numbers_qm,
charges_mm,
xyz_qm,
xyz_mm
);
}
catch (const bp::error_already_set &)
{
PyErr_Print();
throw SireError::process_error(QObject::tr(
"An error occurred when calling the QM Python callback method"),
CODELOC);
}
}
else
{
return bp::call<boost::tuple<double, QVector<QVector<double>>, QVector<QVector<double>>>>(
this->py_object.ptr(),
numbers_qm,
charges_mm,
xyz_qm,
xyz_mm
);
try
{
return bp::call<boost::tuple<double, QVector<QVector<double>>, QVector<QVector<double>>>>(
this->py_object.ptr(),
numbers_qm,
charges_mm,
xyz_qm,
xyz_mm
);
}
catch (const bp::error_already_set &)
{
PyErr_Print();
throw SireError::process_error(QObject::tr(
"An error occurred when calling the QM Python callback method"),
CODELOC);
}
}
}

Expand Down

0 comments on commit 1eb82ff

Please sign in to comment.