Python bindings: Give a detailed error message when passing non-existent name.
List all valid names in the error message. Fix an off-by-one error when accessing elements by numeric index (rather than name). PiperOrigin-RevId: 457702283 Change-Id: I6e4f1518b4ecd9ca91ac9b0bf6b0963fc0a9bd18
This commit is contained in:
committed by
Copybara-Service
parent
a077db1b91
commit
e14cf7ddf1
@@ -185,6 +185,12 @@ class MjDataIndexer {
|
||||
MJDATA_VIEW_GROUPS
|
||||
#undef XGROUP
|
||||
};
|
||||
|
||||
// Returns an error message when a nonexistent name is requested from an
|
||||
// indexer, which includes all valid names.
|
||||
std::string KeyErrorMessage(const NameToIDMap& map, std::string_view name);
|
||||
// Returns an error message when an invalid numeric index is provided.
|
||||
std::string IndexErrorMessage(int index, int size);
|
||||
} // namespace mujoco::python
|
||||
|
||||
#endif // MUJOCO_PYTHON_INDEXERS_H_
|
||||
|
||||
Reference in New Issue
Block a user