diff options
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index d312db272c..2c68c4f400 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -840,6 +840,28 @@ ReturnedValue ExecutionEngine::catchException(ExecutionContext *catchingContext, return res; } +QQmlError ExecutionEngine::convertJavaScriptException(ExecutionContext *context) +{ + QV4::StackTrace trace; + QV4::Scope scope(context); + QV4::ScopedValue exception(scope, context->catchException(&trace)); + QQmlError error; + if (!trace.isEmpty()) { + QV4::StackFrame frame = trace.first(); + error.setUrl(QUrl(frame.source)); + error.setLine(frame.line); + error.setColumn(frame.column); + } + QV4::Scoped<QV4::ErrorObject> errorObj(scope, exception); + if (!!errorObj && errorObj->asSyntaxError()) { + QV4::ScopedString m(scope, errorObj->engine()->newString("message")); + QV4::ScopedValue v(scope, errorObj->get(m)); + error.setDescription(v->toQStringNoThrow()); + } else + error.setDescription(exception->toQStringNoThrow()); + return error; +} + #if !defined(V4_CXX_ABI_EXCEPTION) struct DummyException {}; |