History

Merge pull request #33 from huffman/feat/entity-server-script-property

Fix compilation error and move MessageID to CilentServerUtils

Clément Brisset committed 9 years ago

Commit 6da188b2 parents 95f07f3 be9b19e9 files · +37 −13Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 9 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+8−5
@@ -147,19 +147,22 @@ static bool hasCorrectSyntax(const QScriptProgram& program, ScriptEngine* report · 146 unmodified lines
147 return true;147 return true;
148}148}
149 149
150static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString& exceptionMessage = QString()) {150static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString* exceptionMessage = nullptr) {
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 exceptionMessage = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line);157 QString message = 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 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 return true;166 return true;
164 }167 }
165 return false;168 return false;
@@ -1471,7 +1474,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 1305 unmodified lines
1471 }1474 }
1472 1475
1473 QString exceptionMessage;1476 QString exceptionMessage;
1474 if (hadUncaughtExceptions(sandbox, program.fileName(), this, exceptionMessage)) {1477 if (hadUncaughtExceptions(sandbox, program.fileName(), this, &exceptionMessage)) {
1475 newDetails.status = ERROR_RUNNING_SCRIPT;1478 newDetails.status = ERROR_RUNNING_SCRIPT;
1476 newDetails.errorInfo = exceptionMessage;1479 newDetails.errorInfo = exceptionMessage;
1477 _entityScripts[entityID] = newDetails;1480 _entityScripts[entityID] = newDetails;