Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor bare catch statements to properly print exceptions #84

Open
wants to merge 3 commits into
base: piloting
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*~

.vscode/
12 changes: 10 additions & 2 deletions ethzasl_icp_mapper/src/dynamic_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ void Mapper::processCloud(unique_ptr<DP> new_point_cloud,
- stamp << endl
<< e.what());
return;
} catch (const std::exception &e) {
ROS_ERROR_STREAM("Unexpected exception: " << e.what() << ". Inoring scan.");
return;
} catch (...) {
// Everything else.
ROS_ERROR_STREAM("Unexpected exception... ignoring scan.");
Expand Down Expand Up @@ -461,10 +464,11 @@ void Mapper::updateIcpMap(const DP *new_map_point_cloud) {

icp_.setMap(local_map);
icp_map_lock_.unlock();
} catch (const std::exception &e) {
ROS_ERROR_STREAM("Unexpected exception: " << e.what() << ". Ignoring scan B");
} catch (...) {
// Everything else.
ROS_ERROR_STREAM("Unexpected exception... ignoring scan B");
return;
}
}

Expand Down Expand Up @@ -679,7 +683,11 @@ bool Mapper::correctPose(ethzasl_icp_mapper::CorrectPose::Request &req,
), dim);

updateIcpMap(map_point_cloud_);
} catch (...) {
} catch (const std::exception &e) {
publish_lock_.unlock();
ROS_ERROR_STREAM("Unexpected exception: " << e.what() << ". Inoring scan C");
return false;
} catch (...) {
// everything else
publish_lock_.unlock();
ROS_ERROR_STREAM("Unexpected exception... ignoring scan C");
Expand Down