Sketcher: New function to reuse of python exception message text in the UI

This commit is contained in:
Abdullah Tahiri
2017-04-09 10:00:55 +02:00
committed by wmayer
parent 52a0ad6e04
commit 03d242e202
3 changed files with 16 additions and 2 deletions

View File

@@ -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 {

View File

@@ -98,6 +98,9 @@ void makeTangentToArcOfParabolaviaNewPoint(const Sketcher::SketchObject* Obj,
int geoId1,
int geoId2
);
std::string getStrippedPythonExceptionString(const Base::Exception);
}
#endif // SKETCHERGUI_DrawSketchHandler_H

View File

@@ -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();
}