diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-30 12:59:08 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-30 13:03:36 (GMT) |
commit | 7246727d947e7b7b3e743864005023d609749657 (patch) | |
tree | f55582f721bc3a8221c4b2bb05c35abccdfe6bed | |
parent | 854e71d1335c7d3c2f1f68680f13fe69533125c5 (diff) | |
download | Qt-7246727d947e7b7b3e743864005023d609749657.zip Qt-7246727d947e7b7b3e743864005023d609749657.tar.gz Qt-7246727d947e7b7b3e743864005023d609749657.tar.bz2 |
attempt to return something sensible in uncaughtExceptionBacktrace()
JSC doesn't provide a way to get the backtrace after the exception
has happened (you can only get it at the point it's thrown, by
installing a debugger). As a least effort, we try to use the
uncaught exception to provide a 1-line backtrace (the filename and
linenumber of the innermost call where the exception happened).
-rw-r--r-- | src/script/api/qscriptengine.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 121658a..ee5b076 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2394,10 +2394,16 @@ QStringList QScriptEngine::uncaughtExceptionBacktrace() const { if (!hasUncaughtException()) return QStringList(); - qWarning("QScriptEngine::uncaughtExceptionBacktrace() not implemented"); -// ### implement me - // how do we get a bt with JSC? - return QStringList() << QLatin1String("<backtrace should go here>"); +// ### currently no way to get a full backtrace from JSC without installing a +// debugger that reimplements exception() and store the backtrace there. + QScriptValue value = uncaughtException(); + if (!value.isError()) + return QStringList(); + QStringList result; + result.append(QString::fromLatin1("<anonymous>()@%0:%1") + .arg(value.property(QLatin1String("fileName")).toString()) + .arg(value.property(QLatin1String("lineNumber")).toInt32())); + return result; } /*! |