From 0c7e5323e891e5b32b4bfae58115137e805adfeb Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Fri, 20 Mar 2009 22:41:27 +0000 Subject: Improvements in error handling at Python-C++ boundaries. --- .../BPy_UnaryFunction1DVectorViewShape.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp') diff --git a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp index 4e8e01b2dfa..cf0b73d04ed 100644 --- a/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp +++ b/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp @@ -191,17 +191,20 @@ PyObject * UnaryFunction1DVectorViewShape___call__( BPy_UnaryFunction1DVectorVie { PyObject *obj; - if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) { - cout << "ERROR: UnaryFunction1DVectorViewShape___call__ " << endl; + if( !PyArg_ParseTuple(args, "O!", &Interface1D_Type, &obj) ) return NULL; - } - - std::vector vs( self->uf1D_vectorviewshape->operator()(*( ((BPy_Interface1D *) obj)->if1D )) ); + if (self->uf1D_vectorviewshape->operator()(*( ((BPy_Interface1D *) obj)->if1D )) < 0) { + if (!PyErr_Occurred()) { + string msg(self->uf1D_vectorviewshape->getName() + " __call__ method failed"); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); + } + return NULL; + } PyObject *list = PyList_New(NULL); - for( unsigned int i = 0; i < vs.size(); i++) - PyList_Append(list, BPy_ViewShape_from_ViewShape(*( vs[i] )) ); + for( unsigned int i = 0; i < self->uf1D_vectorviewshape->result.size(); i++) + PyList_Append(list, BPy_ViewShape_from_ViewShape(*( self->uf1D_vectorviewshape->result[i] )) ); return list; } @@ -210,10 +213,8 @@ PyObject * UnaryFunction1DVectorViewShape_setIntegrationType(BPy_UnaryFunction1D { PyObject *obj; - if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) { - cout << "ERROR: UnaryFunction1DVectorViewShape_setIntegrationType " << endl; - Py_RETURN_NONE; - } + if( !PyArg_ParseTuple(args, "O!", &IntegrationType_Type, &obj) ) + return NULL; self->uf1D_vectorviewshape->setIntegrationType( IntegrationType_from_BPy_IntegrationType(obj) ); Py_RETURN_NONE; -- cgit v1.2.3