From cda4c96fa8fb318c00c461d412e837c5e8116641 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 14 Nov 2018 17:47:43 +0100 Subject: [PATCH] Replace Base::Exception with appropriate subclass --- src/Mod/Path/App/Command.cpp | 6 +++--- src/Mod/Path/App/Path.cpp | 6 +++--- src/Mod/Path/App/Tooltable.cpp | 2 +- src/Mod/Robot/App/Edge2TracObject.cpp | 2 +- src/Mod/Robot/App/Robot6AxisPyImp.cpp | 2 +- src/Mod/Robot/App/Trajectory.cpp | 2 +- src/Mod/Robot/App/WaypointPyImp.cpp | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Mod/Path/App/Command.cpp b/src/Mod/Path/App/Command.cpp index a86f7b1c5a..6ff96f0bd7 100644 --- a/src/Mod/Path/App/Command.cpp +++ b/src/Mod/Path/App/Command.cpp @@ -155,7 +155,7 @@ void Command::setFromGCode (const std::string& str) value = ""; mode = "argument"; } else { - throw Base::Exception("Badly formatted GCode command"); + throw Base::BadFormatError("Badly formatted GCode command"); } mode = "argument"; } else if (mode == "none") { @@ -168,7 +168,7 @@ void Command::setFromGCode (const std::string& str) key = ""; value = ""; } else { - throw Base::Exception("Badly formatted GCode argument"); + throw Base::BadFormatError("Badly formatted GCode argument"); } } else if (mode == "comment") { value += str[i]; @@ -198,7 +198,7 @@ void Command::setFromGCode (const std::string& str) Parameters[key] = val; } } else { - throw Base::Exception("Badly formatted GCode argument"); + throw Base::BadFormatError("Badly formatted GCode argument"); } } diff --git a/src/Mod/Path/App/Path.cpp b/src/Mod/Path/App/Path.cpp index 25665f430a..4e0fb05b8d 100644 --- a/src/Mod/Path/App/Path.cpp +++ b/src/Mod/Path/App/Path.cpp @@ -99,7 +99,7 @@ void Toolpath::insertCommand(const Command &Cmd, int pos) Command *tmp = new Command(Cmd); vpcCommands.insert(vpcCommands.begin()+pos,tmp); } else { - throw Base::Exception("Index not in range"); + throw Base::IndexError("Index not in range"); } recalculate(); } @@ -112,7 +112,7 @@ void Toolpath::deleteCommand(int pos) } else if (pos <= static_cast(vpcCommands.size())) { vpcCommands.erase (vpcCommands.begin()+pos); } else { - throw Base::Exception("Index not in range"); + throw Base::IndexError("Index not in range"); } recalculate(); } @@ -282,7 +282,7 @@ void Toolpath::recalculate(void) // recalculates the path cache } } } catch (KDL::Error &e) { - throw Base::Exception(e.Description()); + throw Base::RuntimeError(e.Description()); } #endif } diff --git a/src/Mod/Path/App/Tooltable.cpp b/src/Mod/Path/App/Tooltable.cpp index 53a72d5d53..85cfc89cd7 100644 --- a/src/Mod/Path/App/Tooltable.cpp +++ b/src/Mod/Path/App/Tooltable.cpp @@ -307,7 +307,7 @@ void Tooltable::deleteTool(int pos) if (Tools.find(pos) != Tools.end()) { Tools.erase(pos); } else { - throw Base::Exception("Index not found"); + throw Base::IndexError("Index not found"); } } diff --git a/src/Mod/Robot/App/Edge2TracObject.cpp b/src/Mod/Robot/App/Edge2TracObject.cpp index 4038438dc0..ee4b7ddf3c 100644 --- a/src/Mod/Robot/App/Edge2TracObject.cpp +++ b/src/Mod/Robot/App/Edge2TracObject.cpp @@ -255,7 +255,7 @@ App::DocumentObjectExecReturn *Edge2TracObject::execute(void) } default: - throw Base::Exception("Unknown Edge type in Robot::Edge2TracObject::execute()"); + throw Base::TypeError("Unknown Edge type in Robot::Edge2TracObject::execute()"); } diff --git a/src/Mod/Robot/App/Robot6AxisPyImp.cpp b/src/Mod/Robot/App/Robot6AxisPyImp.cpp index d4aea1e95d..9a636ce6d3 100644 --- a/src/Mod/Robot/App/Robot6AxisPyImp.cpp +++ b/src/Mod/Robot/App/Robot6AxisPyImp.cpp @@ -154,7 +154,7 @@ void Robot6AxisPy::setTcp(Py::Object value) } else if (PyObject_TypeCheck(*value, &(Base::PlacementPy::Type))) { if(! getRobot6AxisPtr()->setTo(*static_cast(*value)->getPlacementPtr())) - throw Base::Exception("Can not reach Point"); + throw Base::RuntimeError("Can not reach Point"); } else { std::string error = std::string("type must be 'Matrix' or 'Placement', not "); diff --git a/src/Mod/Robot/App/Trajectory.cpp b/src/Mod/Robot/App/Trajectory.cpp index 24d9b473a9..61f4532ca2 100644 --- a/src/Mod/Robot/App/Trajectory.cpp +++ b/src/Mod/Robot/App/Trajectory.cpp @@ -228,7 +228,7 @@ void Trajectory::generateTrajectory(void) } } catch (KDL::Error &e) { - throw Base::Exception(e.Description()); + throw Base::RuntimeError(e.Description()); } } diff --git a/src/Mod/Robot/App/WaypointPyImp.cpp b/src/Mod/Robot/App/WaypointPyImp.cpp index aca749576d..f697fc1a43 100644 --- a/src/Mod/Robot/App/WaypointPyImp.cpp +++ b/src/Mod/Robot/App/WaypointPyImp.cpp @@ -176,7 +176,7 @@ Py::String WaypointPy::getType(void) const else if(getWaypointPtr()->Type == Waypoint::UNDEF) return Py::String("UNDEF"); else - throw Base::Exception("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are supported."); + throw Base::TypeError("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are supported."); } void WaypointPy::setType(Py::String arg) @@ -191,7 +191,7 @@ void WaypointPy::setType(Py::String arg) else if(typeStr=="WAIT") getWaypointPtr()->Type = Waypoint::WAIT; else - throw Base::Exception("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are allowed."); + throw Base::TypeError("Unknown waypoint type! Only: PTP,LIN,CIRC,WAIT are allowed."); }