Catch errors in attach during replicate.
PiperOrigin-RevId: 651041336 Change-Id: I59986e157b4e22c74f8b8493899cdd4a3d5df839
This commit is contained in:
committed by
Copybara-Service
parent
b483ce608e
commit
7f9f8b5429
+10
-2
@@ -98,7 +98,11 @@ int mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
||||
const char* prefix, const char* suffix) {
|
||||
mjCFrame* frame_parent = static_cast<mjCFrame*>(parent->element);
|
||||
mjCBody* child_body = static_cast<mjCBody*>(child->element);
|
||||
*frame_parent += std::string(prefix) + *child_body + std::string(suffix);
|
||||
try {
|
||||
*frame_parent += std::string(prefix) + *child_body + std::string(suffix);
|
||||
} catch (mjCError& e) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -109,7 +113,11 @@ int mjs_attachFrame(mjsBody* parent, const mjsFrame* child,
|
||||
const char* prefix, const char* suffix) {
|
||||
mjCBody* body_parent = static_cast<mjCBody*>(parent->element);
|
||||
mjCFrame* child_frame = static_cast<mjCFrame*>(child->element);
|
||||
*body_parent += std::string(prefix) + *child_frame + std::string(suffix);
|
||||
try {
|
||||
*body_parent += std::string(prefix) + *child_frame + std::string(suffix);
|
||||
} catch (mjCError& e) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3437,7 +3437,9 @@ void mjXReader::Body(XMLElement* section, mjsBody* pbody, mjsFrame* frame) {
|
||||
Body(elem, subtree, pframe);
|
||||
|
||||
// attach to parent
|
||||
mjs_attachFrame(pbody, pframe, /*prefix=*/"", suffix.c_str());
|
||||
if (mjs_attachFrame(pbody, pframe, /*prefix=*/"", suffix.c_str()) < 0) {
|
||||
throw mjXError(elem, "failed to attach frame");
|
||||
}
|
||||
}
|
||||
|
||||
// delete subtree
|
||||
|
||||
Reference in New Issue
Block a user