History

Clear script engine errors once they have been reported

So that an error is not repeatedly reported to the console and log file. Also consistently report filename. And scripts included after one in error will now be run.

David Rowe committed 12 years ago

Commit e92ad861 parent 3b4ac911 file · +11 −8Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−8
@@ -314,8 +314,9 @@ void ScriptEngine::evaluate() { · 313 unmodified lines
314314
315315 if (_engine.hasUncaughtException()) {
316316 int line = _engine.uncaughtExceptionLineNumber();
317− qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
318− emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
317+ qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString();
318+ emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString());
319+ _engine.clearExceptions();
319320 }
320321 }
321322
@@ -324,7 +325,7 @@ QScriptValue ScriptEngine::evaluate(const QString& program, const QString& fileN · 2 unmodified lines
324325 bool hasUncaughtException = _engine.hasUncaughtException();
325326 if (hasUncaughtException) {
326327 int line = _engine.uncaughtExceptionLineNumber();
327− qDebug() << "Uncaught exception at line" << line << ": " << result.toString();
328+ qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ": " << result.toString();
328329 }
329330 emit evaluationFinished(result, hasUncaughtException);
330331 _engine.clearExceptions();
@@ -353,9 +354,9 @@ void ScriptEngine::run() { · 22 unmodified lines
353354 QScriptValue result = _engine.evaluate(_scriptContents);
354355 if (_engine.hasUncaughtException()) {
355356 int line = _engine.uncaughtExceptionLineNumber();
356−
357− qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
358− emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
357+ qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString();
358+ emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString());
359+ _engine.clearExceptions();
359360 }
360361
361362 QElapsedTimer startTime;
@@ -495,8 +496,9 @@ void ScriptEngine::run() { · 133 unmodified lines
495496
496497 if (_engine.hasUncaughtException()) {
497498 int line = _engine.uncaughtExceptionLineNumber();
498− qDebug() << "Uncaught exception at line" << line << ":" << _engine.uncaughtException().toString();
499− emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + _engine.uncaughtException().toString());
499+ qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << _engine.uncaughtException().toString();
500+ emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + _engine.uncaughtException().toString());
501+ _engine.clearExceptions();
500502 }
501503 }
502504 emit scriptEnding();
@@ -656,5 +658,6 @@ void ScriptEngine::include(const QString& includeFile) { · 153 unmodified lines
656658 int line = _engine.uncaughtExceptionLineNumber();
657659 qDebug() << "Uncaught exception at (" << includeFile << ") line" << line << ":" << result.toString();
658660 emit errorMessage("Uncaught exception at (" + includeFile + ") line" + QString::number(line) + ":" + result.toString());
661+ _engine.clearExceptions();
659662 }
660663 }