Skip to content

Commit

Permalink
Catch exceptions in connect functions
Browse files Browse the repository at this point in the history
  • Loading branch information
marip8 committed May 29, 2024
1 parent d3a1252 commit c35206b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions snp_application/src/snp_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ SNPWidget::SNPWidget(rclcpp::Node::SharedPtr rviz_node, QWidget* parent)
ui_->stacked_widget->setCurrentIndex(0);
ui_->group_box_operation->setEnabled(true);

auto bt_tree_name = snp_application::get_parameter<std::string>(bt_node_, BT_PARAM);
if (bt_tree_name.empty())
QMessageBox::warning(this, QString::fromStdString("Error"),
QString::fromStdString("Parameter '" + BT_PARAM + "' is not set"));

runTreeWithThread(bt_tree_name);
try
{
runTreeWithThread(snp_application::get_parameter<std::string>(bt_node_, BT_PARAM));
}
catch (const std::exception& ex)
{
QMessageBox::warning(this, "Error", ex.what());
}
});

// Go Home
Expand All @@ -116,12 +118,14 @@ SNPWidget::SNPWidget(rclcpp::Node::SharedPtr rviz_node, QWidget* parent)
ui_->stacked_widget->setCurrentIndex(0);
ui_->group_box_operation->setEnabled(true);

auto bt_tree_name = snp_application::get_parameter<std::string>(bt_node_, BT_FREESPACE_PARAM);
if (bt_tree_name.empty())
QMessageBox::warning(this, QString::fromStdString("Error"),
QString::fromStdString("Parameter '" + BT_FREESPACE_PARAM + "' is not set"));

runTreeWithThread(bt_tree_name);
try
{
runTreeWithThread(snp_application::get_parameter<std::string>(bt_node_, BT_FREESPACE_PARAM));
}
catch (const std::exception& ex)
{
QMessageBox::warning(this, "Error", ex.what());
}
});

// Move the text edit scroll bar to the maximum limit whenever it is resized
Expand Down

0 comments on commit c35206b

Please sign in to comment.