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