From 257c4456a18d9b99db93b44db42312f00fc6a57c Mon Sep 17 00:00:00 2001 From: Florent Lamiraux <florent@laas.fr> Date: Mon, 21 Mar 2011 16:35:53 +0100 Subject: [PATCH] Return a python error instead of throwing C++ exception. --- src/entity-py.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/entity-py.cc b/src/entity-py.cc index 8e2ec8d..dd24338 100644 --- a/src/entity-py.cc +++ b/src/entity-py.cc @@ -54,9 +54,16 @@ namespace dynamicgraph { /* Try to find if the corresponding object already exists. */ if( dynamicgraph::g_pool.existEntity( instanceName,obj ) ) { - if( obj->getClassName()!=className ) - throw ExceptionPython( ExceptionPython::CLASS_INCONSISTENT, - "Found an object with the same name but of different class." ); + if( obj->getClassName()!=className ) { + std::string msg ("Found an object named " + + std::string(instanceName) + + ",\n""but this object is of type " + + std::string(obj->getClassName()) + + " and not " + + std::string(className)); + PyErr_SetString(dgpyError, msg.c_str()); + return NULL; + } } else /* If not, create a new object. */ { -- GitLab