Raise ValueError if adding a spec results in a duplicate name.

PiperOrigin-RevId: 871397807
Change-Id: I50742efe7ba194ed3b1fe916f05e35b7fb2d7ec0
This commit is contained in:
Sam Haves
2026-02-17 10:53:35 -08:00
committed by Copybara-Service
parent af802a5386
commit 448e221690
2 changed files with 23 additions and 1 deletions
@@ -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)));
}
}
};
"""