From 0a986ddca6c87df36c235192c5bb0a83b0e13f87 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 7 Jul 2014 13:56:23 +0200 Subject: [PATCH] + give more information when assigning wrong type to quantity property --- src/App/PropertyUnits.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp index 04a4ca268..7a7d05bd3 100644 --- a/src/App/PropertyUnits.cpp +++ b/src/App/PropertyUnits.cpp @@ -83,7 +83,8 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject *value) Str = PyString_AsString(unicode); quant = Quantity::parse(QString::fromUtf8(Str.c_str())); Py_DECREF(unicode); - }else if (PyFloat_Check(value)) + } + else if (PyFloat_Check(value)) quant = Quantity(PyFloat_AsDouble(value),_Unit); else if (PyInt_Check(value)) quant = Quantity((double)PyInt_AsLong(value),_Unit); @@ -91,8 +92,11 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject *value) Base::QuantityPy *pcObject = static_cast(value); quant = *(pcObject->getQuantityPtr()); } - else - throw Base::Exception("Wrong type!"); + else { + std::string error = std::string("wrong type as quantity: "); + error += value->ob_type->tp_name; + throw Base::TypeError(error); + } return quant; }