Raise ValueError if adding a spec results in a duplicate name.
PiperOrigin-RevId: 871397807 Change-Id: I50742efe7ba194ed3b1fe916f05e35b7fb2d7ec0
This commit is contained in:
committed by
Copybara-Service
parent
af802a5386
commit
448e221690
@@ -841,7 +841,9 @@ def generate_add() -> None:
|
||||
code += """\n
|
||||
auto set_name = [](raw::MjsElement* el, const std::optional<std::string>& name) {
|
||||
if (name.has_value()) {
|
||||
mjs_setName(el, name->c_str());
|
||||
if (mjs_setName(el, name->c_str())) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(el)));
|
||||
}
|
||||
}
|
||||
};
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user