From cb1b32ee1579b5ee2fb603df6b1add6b3e4ffd58 Mon Sep 17 00:00:00 2001 From: Dereck Wonnacott <44446780+dawonn-haval@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:42:49 -0400 Subject: [PATCH] Include original exception in ComponentManagerException (#1157) (#1223) * Include original exception in ComponentManagerException Signed-off-by: Martijn Buijs * Update rclcpp_components/src/component_manager.cpp Co-authored-by: tomoya Signed-off-by: Martijn Buijs Co-authored-by: tomoya Co-authored-by: Martijn Buijs Co-authored-by: tomoya --- rclcpp_components/src/component_manager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rclcpp_components/src/component_manager.cpp b/rclcpp_components/src/component_manager.cpp index a80fada..bfb1b5c 100644 --- a/rclcpp_components/src/component_manager.cpp +++ b/rclcpp_components/src/component_manager.cpp @@ -196,6 +196,11 @@ ComponentManager::OnLoadNode( try { node_wrappers_[node_id] = factory->create_node_instance(options); + } catch (const std::exception & ex) { + // In the case that the component constructor throws an exception, + // rethrow into the following catch block. + throw ComponentManagerException( + "Component constructor threw an exception: " + std::string(ex.what())); } catch (...) { // In the case that the component constructor throws an exception, // rethrow into the following catch block.