From 47cf75a0aa7e997d49c8fe778ee89404685b960c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Mon, 8 Feb 2021 14:36:05 +0800 Subject: [PATCH] optimize stack trace print --- doric-Qt/doric/engine/DoricNativeJSE.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doric-Qt/doric/engine/DoricNativeJSE.cpp b/doric-Qt/doric/engine/DoricNativeJSE.cpp index c2f643e1..9724b457 100644 --- a/doric-Qt/doric/engine/DoricNativeJSE.cpp +++ b/doric-Qt/doric/engine/DoricNativeJSE.cpp @@ -1,5 +1,8 @@ -#include "DoricNativeJSE.h" #include +#include + +#include "../utils/DoricUtils.h" +#include "DoricNativeJSE.h" DoricNativeJSE::DoricNativeJSE() { mJSEngine.installExtensions(QJSEngine::AllExtensions); @@ -34,6 +37,9 @@ void DoricNativeJSE::injectGlobalJSFunction(QString name, QObject *function, QJSValue DoricNativeJSE::invokeObject(QString objectName, QString functionName, QVariantList arguments) { + QString script = DoricUtils::readAssetFile("/test", "test.js"); + mJSEngine.evaluate(script); + QJSValue object = mJSEngine.evaluate(objectName); QJSValue function = object.property(functionName); @@ -58,13 +64,11 @@ QJSValue DoricNativeJSE::invokeObject(QString objectName, QString functionName, QJSValue result = function.call(args); if (result.isError()) { - qDebug() << "++++++++++++++++++++++++"; - qCritical() << "Uncaught exception at line" - << result.property("lineNumber").toInt() << ":" - << result.toString(); + qCritical() << "++++++++++++++++++++++++++++++++++++++++++++++++"; + qCritical() << result.toString(); QStringList stacktraces = result.property("stack").toString().split("\n"); foreach (QString stacktrace, stacktraces) { qDebug() << stacktrace; } - qDebug() << "------------------------"; + qCritical() << "------------------------------------------------"; } return result;