Skip to content

Commit

Permalink
use custom exception type for better error messages/catching
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed May 30, 2022
1 parent c2d9e64 commit d4404cf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions arm_robots/src/arm_robots/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class RobotPlanningError(Exception):
pass


class FollowJointTrajectoryError(Exception):
pass


def on_error(message):
rospy.logdebug(message, logger_name='urdf_parser_py')

Expand Down Expand Up @@ -291,8 +295,9 @@ def _feedback_cb(feedback: FollowJointTrajectoryFeedback):
failure = (result is None or result.error_code != FollowJointTrajectoryResult.SUCCESSFUL)
if self.raise_on_failure and failure:
if result is not None:
raise RuntimeError(f"Follow Joint Trajectory Failed: ({result.error_code}) {result.error_string}")
raise RuntimeError(f"Follow Joint Trajectory Failed: (???)")
raise FollowJointTrajectoryError(
f"Follow Joint Trajectory Failed: ({result.error_code}) {result.error_string}")
raise FollowJointTrajectoryError(f"Follow Joint Trajectory Failed: (???)")

success = result is not None and result.error_code == FollowJointTrajectoryResult.SUCCESSFUL
return ExecutionResult(trajectory=trajectory,
Expand Down

0 comments on commit d4404cf

Please sign in to comment.