PR FIxes
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 5 files). Show all
Unified · Split
| @@ -147,19 +147,19 @@ static bool hasCorrectSyntax(const QScriptProgram& program, ScriptEngine* report · 146 unmodified lines | |||
| 147 | return true; | 147 | return true; |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine) { | 150 | static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString& exceptionMessage = QString()) { |
| 151 | if (engine.hasUncaughtException()) { | 151 | if (engine.hasUncaughtException()) { |
| 152 | const auto backtrace = engine.uncaughtExceptionBacktrace(); | 152 | const auto backtrace = engine.uncaughtExceptionBacktrace(); |
| 153 | const auto exception = engine.uncaughtException().toString(); | 153 | const auto exception = engine.uncaughtException().toString(); |
| 154 | const auto line = QString::number(engine.uncaughtExceptionLineNumber()); | 154 | const auto line = QString::number(engine.uncaughtExceptionLineNumber()); |
| 155 | engine.clearExceptions(); | 155 | engine.clearExceptions(); |
| 156 | 156 | ||
| 157 | auto message = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line); | 157 | exceptionMessage = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line); |
| 158 | if (!backtrace.empty()) { | 158 | if (!backtrace.empty()) { |
| 159 | static const auto lineSeparator = "\n "; | 159 | static const auto lineSeparator = "\n "; |
| 160 | message += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator)); | 160 | exceptionMessage += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator)); |
| 161 | } | 161 | } |
| 162 | reportingEngine->scriptErrorMessage(qPrintable(message)); | 162 | reportingEngine->scriptErrorMessage(qPrintable(exceptionMessage)); |
| 163 | return true; | 163 | return true; |
| 164 | } | 164 | } |
| 165 | return false; | 165 | return false; |
| @@ -1469,9 +1469,11 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 1303 unmodified lines | |||
| 1469 | }); | 1469 | }); |
| 1470 | testConstructor = sandbox.evaluate(program); | 1470 | testConstructor = sandbox.evaluate(program); |
| 1471 | } | 1471 | } |
| 1472 | if (hadUncaughtExceptions(sandbox, program.fileName(), this)) { | 1472 | |
| 1473 | QString exceptionMessage; | ||
| 1474 | if (hadUncaughtExceptions(sandbox, program.fileName(), this, exceptionMessage)) { | ||
| 1473 | newDetails.status = ERROR_RUNNING_SCRIPT; | 1475 | newDetails.status = ERROR_RUNNING_SCRIPT; |
| 1474 | newDetails.errorInfo = "Exception"; | 1476 | newDetails.errorInfo = exceptionMessage; |
| 1475 | _entityScripts[entityID] = newDetails; | 1477 | _entityScripts[entityID] = newDetails; |
| 1476 | 1478 | ||
| 1477 | return; | 1479 | return; |