From b6d18ccc813d9f35b080795de764b1730702981a Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 19 Sep 2019 13:15:19 -0700 Subject: [PATCH] add more context to exception message (#858) * add more context to exception message Signed-off-by: Dirk Thomas * fix linter warnings Signed-off-by: Dirk Thomas --- rclcpp/src/rclcpp/time.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/time.cpp b/rclcpp/src/rclcpp/time.cpp index 980b6a5..b7f0bd2 100644 --- a/rclcpp/src/rclcpp/time.cpp +++ b/rclcpp/src/rclcpp/time.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include #include "rclcpp/clock.hpp" @@ -194,7 +195,10 @@ Duration Time::operator-(const rclcpp::Time & rhs) const { if (rcl_time_.clock_type != rhs.rcl_time_.clock_type) { - throw std::runtime_error("can't subtract times with different time sources"); + throw std::runtime_error( + std::string("can't subtract times with different time sources [") + + std::to_string(rcl_time_.clock_type) + " != " + + std::to_string(rhs.rcl_time_.clock_type) + "]"); } if (rclcpp::sub_will_overflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {