From 7246727d947e7b7b3e743864005023d609749657 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 30 Jul 2009 14:59:08 +0200 Subject: 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). --- src/script/api/qscriptengine.cpp | 14 ++++++++++---- 1 file 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(""); +// ### 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("()@%0:%1") + .arg(value.property(QLatin1String("fileName")).toString()) + .arg(value.property(QLatin1String("lineNumber")).toInt32())); + return result; } /*! -- cgit v0.12