Skip to content
Snippets Groups Projects
Commit 64545832 authored by Fabian Reister's avatar Fabian Reister
Browse files

removing code duplication (review)

parent 40f14b83
No related branches found
No related tags found
2 merge requests!157armem/dev => master,!141Feature/armem object memory articulated objects
This commit is part of merge request !157. Comments created here will be created in the context of that merge request.
......@@ -84,60 +84,43 @@ namespace armarx::armem::server::obj
instance::SegmentAdapter::init();
// class segment
try
const auto initSegmentWithCatch = [&](const std::string & segmentName, const auto&& fn)
{
classSegment.init();
}
catch (const LocalException& e)
{
ARMARX_ERROR << "Failed to init class segment. Reason: \n" << e.what();
}
catch (const std::exception& e)
{
ARMARX_ERROR << "Failed to init class segment. Reason: \n" << e.what();
}
catch (...)
try
{
fn();
}
catch (const LocalException& e)
{
ARMARX_ERROR << "Failed to init " << segmentName << " segment. Reason: \n" << e.what();
}
catch (const std::exception& e)
{
ARMARX_ERROR << "Failed to init " << segmentName << " segment. Reason: \n" << e.what();
}
catch (...)
{
ARMARX_ERROR << "Failed to init " << segmentName << " segment for unknown reason.";
}
};
initSegmentWithCatch("class", [&]()
{
ARMARX_ERROR << "Failed to init class segment for unknown reason.";
}
classSegment.init();
});
// articulated object class segment
try
initSegmentWithCatch("articulated object class", [&]()
{
articulatedObjectClassSegment.init();
}
catch (const LocalException& e)
{
ARMARX_ERROR << "Failed to init class segment. Reason: \n" << e.what();
}
catch (const std::exception& e)
{
ARMARX_ERROR << "Failed to init class segment. Reason: \n" << e.what();
}
catch (...)
{
ARMARX_ERROR << "Failed to init class segment for unknown reason.";
}
});
// articulated object instance segment
try
initSegmentWithCatch("articulated object instance", [&]()
{
articulatedObjectInstanceSegment.setArticulatedObjectClassSegment(articulatedObjectClassSegment);
articulatedObjectInstanceSegment.init();
}
catch (const LocalException& e)
{
ARMARX_ERROR << "Failed to init class segment. Reason: \n" << e.what();
}
catch (const std::exception& e)
{
ARMARX_ERROR << "Failed to init class segment. Reason: \n" << e.what();
}
catch (...)
{
ARMARX_ERROR << "Failed to init class segment for unknown reason.";
}
});
}
void ObjectMemory::onConnectComponent()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment