Skip to content

Commit

Permalink
Print SDL error on IMG_Load failure in server_map (ros-planning#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alabate authored and gerkey committed Jan 19, 2018
1 parent 6222444 commit 9b3b9ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion map_server/src/image_loader.cpp
Expand Up @@ -76,7 +76,7 @@ loadMapFromFile(nav_msgs::GetMap::Response* resp,
if(!(img = IMG_Load(fname)))
{
std::string errmsg = std::string("failed to open image file \"") +
std::string(fname) + std::string("\"");
std::string(fname) + std::string("\": ") + IMG_GetError();
throw std::runtime_error(errmsg);
}

Expand Down
10 changes: 9 additions & 1 deletion map_server/src/main.cpp
Expand Up @@ -165,7 +165,15 @@ class MapServer
}

ROS_INFO("Loading map from image \"%s\"", mapfname.c_str());
map_server::loadMapFromFile(&map_resp_,mapfname.c_str(),res,negate,occ_th,free_th, origin, mode);
try
{
map_server::loadMapFromFile(&map_resp_,mapfname.c_str(),res,negate,occ_th,free_th, origin, mode);
}
catch (std::runtime_error e)
{
ROS_ERROR("%s", e.what());
exit(-1);
}
map_resp_.map.info.map_load_time = ros::Time::now();
map_resp_.map.header.frame_id = frame_id;
map_resp_.map.header.stamp = ros::Time::now();
Expand Down

0 comments on commit 9b3b9ac

Please sign in to comment.