From 7768bad674ad1e1b5272b268a62cb5c1cfb70bdb Mon Sep 17 00:00:00 2001 From: Felix Glinka Date: Wed, 19 Aug 2020 12:51:39 +0200 Subject: [PATCH 1/3] Use more specialized exceptions --- tasks/Conversions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/Conversions.cpp b/tasks/Conversions.cpp index a313d05..0ba43b3 100644 --- a/tasks/Conversions.cpp +++ b/tasks/Conversions.cpp @@ -99,7 +99,7 @@ void jointState2RmlTypes(const base::samples::Joints& joint_state, const std::ve params.CurrentVelocityVector->VecData[i] = 0; params.CurrentAccelerationVector->VecData[i] = 0; } - catch(std::runtime_error e){ + catch(const std::out_of_range &e){ LOG_ERROR("Element %s has been configured in motion constraints, but is not available in joint state", names[i].c_str()); throw e; } @@ -207,7 +207,7 @@ void target2RmlTypes(const ConstrainedJointsCmd& target, const MotionConstraints motionConstraint2RmlTypes(constraint, idx, params); } } - catch(std::runtime_error e){ + catch(const MotionConstraints::InvalidName &e){ LOG_ERROR("Joint '%s' is in target vector but has not been configured in motion constraints", target.names[i].c_str()); throw e; } @@ -227,7 +227,7 @@ void target2RmlTypes(const ConstrainedJointsCmd& target, const MotionConstraints motionConstraint2RmlTypes(constraint, idx, params); } } - catch(std::runtime_error e){ + catch(const MotionConstraints::InvalidName &e){ LOG_ERROR("Joint '%s' is in target vector but has not been configured in motion constraints", target.names[i].c_str()); throw e; } From ac5b3141b4efc04d2da58430d3cdf500046f09f3 Mon Sep 17 00:00:00 2001 From: Felix Glinka Date: Fri, 28 Aug 2020 12:28:54 +0200 Subject: [PATCH 2/3] Fix exception type for joint state --- tasks/Conversions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/Conversions.cpp b/tasks/Conversions.cpp index 0ba43b3..dd6f3d1 100644 --- a/tasks/Conversions.cpp +++ b/tasks/Conversions.cpp @@ -99,7 +99,7 @@ void jointState2RmlTypes(const base::samples::Joints& joint_state, const std::ve params.CurrentVelocityVector->VecData[i] = 0; params.CurrentAccelerationVector->VecData[i] = 0; } - catch(const std::out_of_range &e){ + catch(const base::samples::Joints::InvalidName &e){ LOG_ERROR("Element %s has been configured in motion constraints, but is not available in joint state", names[i].c_str()); throw e; } From cef4993f6d679e72a8833d7dcccef3c111003058 Mon Sep 17 00:00:00 2001 From: Felix Glinka Date: Fri, 28 Aug 2020 12:47:21 +0200 Subject: [PATCH 3/3] Extract joint names in error messages from exception --- tasks/Conversions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/Conversions.cpp b/tasks/Conversions.cpp index dd6f3d1..7570486 100644 --- a/tasks/Conversions.cpp +++ b/tasks/Conversions.cpp @@ -100,7 +100,7 @@ void jointState2RmlTypes(const base::samples::Joints& joint_state, const std::ve params.CurrentAccelerationVector->VecData[i] = 0; } catch(const base::samples::Joints::InvalidName &e){ - LOG_ERROR("Element %s has been configured in motion constraints, but is not available in joint state", names[i].c_str()); + LOG_ERROR("Element %s has been configured in motion constraints, but is not available in joint state", e.name.c_str()); throw e; } } @@ -208,7 +208,7 @@ void target2RmlTypes(const ConstrainedJointsCmd& target, const MotionConstraints } } catch(const MotionConstraints::InvalidName &e){ - LOG_ERROR("Joint '%s' is in target vector but has not been configured in motion constraints", target.names[i].c_str()); + LOG_ERROR("Joint '%s' is in target vector but has not been configured in motion constraints", e.name.c_str()); throw e; } } @@ -228,7 +228,7 @@ void target2RmlTypes(const ConstrainedJointsCmd& target, const MotionConstraints } } catch(const MotionConstraints::InvalidName &e){ - LOG_ERROR("Joint '%s' is in target vector but has not been configured in motion constraints", target.names[i].c_str()); + LOG_ERROR("Joint '%s' is in target vector but has not been configured in motion constraints", e.name.c_str()); throw e; } }