Skip to content

Commit 32e66f4

Browse files
[SceneLoader] Add a special error message handler for DeprecationWarning (#384)
* [SofaPython3/Plugin] Add a special error message handler for DeprecationWarning Otherwise deprecation messages appears as error which is misleading for users. * Update Plugin/src/SofaPython3/SceneLoaderPY3.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> --------- Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
1 parent 8791248 commit 32e66f4

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

Plugin/src/SofaPython3/SceneLoaderPY3.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,18 @@ void SceneLoaderPY3::loadSceneWithArguments(const char *filename,
129129
root_out->setInstanciationSourceFilePos(0);
130130
}catch(py::error_already_set& e)
131131
{
132-
msg_error() << "Unable to completely load the scene from file '"<< filename << "'." << msgendl
133-
<< "Python exception: " << msgendl
134-
<< " " << e.what();
132+
std::stringstream ss;
133+
ss << "Unable to completely load the scene from file '"<< filename << "'." << msgendl
134+
<< "Python exception: " << msgendl
135+
<< " " << e.what();
136+
if( py::isinstance(e.type(), py::eval("type(DeprecationWarning)")) )
137+
{
138+
msg_deprecated() << ss.str();
139+
}else
140+
{
141+
msg_error() << ss.str();
142+
}
143+
135144
}
136145

137146
}

0 commit comments

Comments
 (0)