1
0
mirror of https://github.com/thp/pyotherside.git synced 2025-01-17 23:22:53 +08:00

Better error reporting (also print everything to the console)

This commit is contained in:
Thomas Perl 2014-01-04 13:14:36 +01:00
parent ee11e74822
commit c14a983713
2 changed files with 7 additions and 5 deletions

View File

@ -99,7 +99,7 @@ QPython::importModule_sync(QString name)
priv->enter();
PyObject *module = PyImport_ImportModule(moduleName);
if (module == NULL) {
emit error(priv->formatExc());
emit error(QString("Cannot import module: %1 (%2)").arg(name).arg(priv->formatExc()));
priv->leave();
return false;
}
@ -143,7 +143,7 @@ QPython::evaluate(QString expr)
priv->enter();
PyObject *o = priv->eval(expr);
if (o == NULL) {
emit error(priv->formatExc());
emit error(QString("Cannot evaluate '%1' (%2)").arg(expr).arg(priv->formatExc()));
priv->leave();
return QVariant();
}
@ -167,7 +167,7 @@ QPython::call_sync(QString func, QVariant args)
PyObject *callable = priv->eval(func);
if (callable == NULL) {
emit error(priv->formatExc());
emit error(QString("Function not found: '%1' (%2)").arg(func).arg(priv->formatExc()));
priv->leave();
return QVariant();
}
@ -183,7 +183,7 @@ QPython::call_sync(QString func, QVariant args)
Py_DECREF(argt);
if (o == NULL) {
emit error(priv->formatExc());
emit error(QString("Return value of PyObject call is NULL: %1").arg(priv->formatExc()));
} else {
v = convertPyObjectToQVariant(o);
Py_DECREF(o);
@ -194,7 +194,7 @@ QPython::call_sync(QString func, QVariant args)
return v;
}
emit error(QString("Not a callable: ") + func);
emit error(QString("Not a callable: %1").arg(func));
Py_DECREF(callable);
priv->leave();
return QVariant();

View File

@ -21,6 +21,7 @@
#include "qpython_priv.h"
#include <QImage>
#include <QDebug>
static QPythonPriv *priv = NULL;
@ -239,6 +240,7 @@ cleanup:
Py_XDECREF(value);
Py_XDECREF(traceback);
qDebug() << QString("PyOtherSide error: %1").arg(message);
return message;
}