Mark mjCError and mjXError as [[nodiscard]].

This lets the compiler catch the mistake of creating an exception without throwing it.

PiperOrigin-RevId: 474536776
Change-Id: I5bd18258ce6ddd266adb1c852b1ba9e3063cd0b2
This commit is contained in:
Nimrod Gileadi
2022-09-15 05:28:18 -07:00
committed by Copybara-Service
parent 0a0acb3419
commit c8517e63a4
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ typedef enum _mjtMeshType {
// error information
class mjCError {
class [[nodiscard]] mjCError {
public:
mjCError(const mjCBase* obj = 0,
const char* msg = 0,
+2 -2
View File
@@ -308,7 +308,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
ReadAttrTxt(joint_elem, "type", text, true);
jointtype = FindKey(urJoint_map, urJoint_sz, text);
if (jointtype < 0) {
mjXError(joint_elem, "invalid joint type in URDF joint definition");
throw mjXError(joint_elem, "invalid joint type in URDF joint definition");
}
ReadAttrTxt(joint_elem, "name", jntname, true);
@@ -317,7 +317,7 @@ void mjXURDF::Joint(XMLElement* joint_elem) {
ReadAttrTxt(elem, "link", name, true);
parent = (mjCBody*) model->GetWorld()->FindObject(mjOBJ_BODY, name);
if (!parent) { // SHOULD NOT OCCUR
mjXError(elem, "invalid parent name in URDF joint definition");
throw mjXError(elem, "invalid parent name in URDF joint definition");
}
// get child=this, check
+1 -1
View File
@@ -33,7 +33,7 @@ void mjCopyError(char* dst, const char* src, int maxlen);
// XML Error info
class mjXError {
class [[nodiscard]] mjXError {
public:
mjXError(const tinyxml2::XMLElement* elem = 0,
const char* msg = 0,