When reporting compilation errors, include warning strings.

This allows plugins to call mju_warning, and have the string propagate to users.

PiperOrigin-RevId: 650621601
Change-Id: I608e7a3a1ad126ab8da2ff0634fa708458fb9ccc
This commit is contained in:
Nimrod Gileadi
2024-07-09 07:32:26 -07:00
committed by Copybara-Service
parent 450e7ff777
commit c5f958bdff
3 changed files with 11 additions and 4 deletions
+8 -1
View File
@@ -3257,7 +3257,14 @@ mjModel* mjCModel::Compile(const mjVFS* vfs, mjModel** m) {
try {
if (setjmp(error_jmp_buf) != 0) {
// TryCompile resulted in an mju_error which was converted to a longjmp.
throw mjCError(0, "engine error: %s", errortext);
std::string error_msg = errortext;
// also include the last warning that was issued. this is useful for
// warnings that came out of plugin implementations.
if (warningtext[0]) {
error_msg += "\n";
error_msg += warningtext;
}
throw mjCError(0, "engine error: %s", error_msg.c_str());
}
TryCompile(*const_cast<mjModel**>(&model), *const_cast<mjData**>(&data), vfs);
} catch (mjCError err) {