mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Add exception information to script status
This commit is contained in:
parent
4e358f76fe
commit
888d7ab03d
1 changed files with 8 additions and 6 deletions
|
@ -147,19 +147,19 @@ static bool hasCorrectSyntax(const QScriptProgram& program, ScriptEngine* report
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine) {
|
static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString& exceptionMessage = QString()) {
|
||||||
if (engine.hasUncaughtException()) {
|
if (engine.hasUncaughtException()) {
|
||||||
const auto backtrace = engine.uncaughtExceptionBacktrace();
|
const auto backtrace = engine.uncaughtExceptionBacktrace();
|
||||||
const auto exception = engine.uncaughtException().toString();
|
const auto exception = engine.uncaughtException().toString();
|
||||||
const auto line = QString::number(engine.uncaughtExceptionLineNumber());
|
const auto line = QString::number(engine.uncaughtExceptionLineNumber());
|
||||||
engine.clearExceptions();
|
engine.clearExceptions();
|
||||||
|
|
||||||
auto message = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line);
|
exceptionMessage = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line);
|
||||||
if (!backtrace.empty()) {
|
if (!backtrace.empty()) {
|
||||||
static const auto lineSeparator = "\n ";
|
static const auto lineSeparator = "\n ";
|
||||||
message += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator));
|
exceptionMessage += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator));
|
||||||
}
|
}
|
||||||
reportingEngine->scriptErrorMessage(qPrintable(message));
|
reportingEngine->scriptErrorMessage(qPrintable(exceptionMessage));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1472,9 +1472,11 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co
|
||||||
});
|
});
|
||||||
testConstructor = sandbox.evaluate(program);
|
testConstructor = sandbox.evaluate(program);
|
||||||
}
|
}
|
||||||
if (hadUncaughtExceptions(sandbox, program.fileName(), this)) {
|
|
||||||
|
QString exceptionMessage;
|
||||||
|
if (hadUncaughtExceptions(sandbox, program.fileName(), this, exceptionMessage)) {
|
||||||
newDetails.status = ERROR_RUNNING_SCRIPT;
|
newDetails.status = ERROR_RUNNING_SCRIPT;
|
||||||
newDetails.errorInfo = "Exception";
|
newDetails.errorInfo = exceptionMessage;
|
||||||
_entityScripts[entityID] = newDetails;
|
_entityScripts[entityID] = newDetails;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue