Sketcher: New function to reuse of python exception message text in the UI
This commit is contained in:
@@ -674,6 +674,17 @@ void SketcherGui::makeTangentToArcOfParabolaviaNewPoint(const Sketcher::SketchOb
|
||||
Gui::Command::updateActive();
|
||||
}
|
||||
|
||||
std::string SketcherGui::getStrippedPythonExceptionString(const Base::Exception e)
|
||||
{
|
||||
std::string msg = e.what();
|
||||
|
||||
if( msg.length() > 26 && msg.substr(0,26) == "FreeCAD exception thrown (") {
|
||||
return msg.substr(26, msg.length()-27);
|
||||
}
|
||||
else
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
namespace SketcherGui {
|
||||
|
||||
|
||||
@@ -98,6 +98,9 @@ void makeTangentToArcOfParabolaviaNewPoint(const Sketcher::SketchObject* Obj,
|
||||
int geoId1,
|
||||
int geoId2
|
||||
);
|
||||
|
||||
std::string getStrippedPythonExceptionString(const Base::Exception);
|
||||
|
||||
}
|
||||
#endif // SKETCHERGUI_DrawSketchHandler_H
|
||||
|
||||
|
||||
@@ -572,7 +572,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg)
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"),
|
||||
QObject::tr(e.what()));
|
||||
QObject::tr(getStrippedPythonExceptionString(e).c_str()));
|
||||
getSelection().clearSelection();
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Error"),
|
||||
QObject::tr(e.what()));
|
||||
QObject::tr(getStrippedPythonExceptionString(e).c_str()));
|
||||
getSelection().clearSelection();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user