From 13a64d60ea489f42370f869bd7a5bb281269b435 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Tue, 20 Dec 2022 21:41:21 +0530 Subject: [PATCH] [Sketcher] Handle exception in Python while splitting `SketchObject::split` only appears to throw `ValueError`. --- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 0822210692..740b37158a 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -1154,11 +1154,16 @@ PyObject* SketchObjectPy::split(PyObject *args) return nullptr; Base::Vector3d v1 = static_cast(pcObj)->value(); - if (this->getSketchObjectPtr()->split(GeoId,v1)) { - std::stringstream str; - str << "Not able to split curve with the given index: " << GeoId; - PyErr_SetString(PyExc_ValueError, str.str().c_str()); - return nullptr; + try { + if (this->getSketchObjectPtr()->split(GeoId,v1)) { + std::stringstream str; + str << "Not able to split curve with the given index: " << GeoId; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return nullptr; + } + } + catch (const Base::ValueError & e) { + throw Py::ValueError(e.getMessage()); } Py_Return;