Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -50,6 +50,8 @@ · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | #include "MIDIEvent.h" |
| 52 | 52 | |
| 53 | +static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3"; | |
| 54 | + | |
| 53 | 55 | Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature) |
| 54 | 56 | static int functionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>(); |
| 55 | 57 | |
| @@ -111,7 +113,7 @@ static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName · 55 unmodified lines | ||
| 111 | 113 | const auto line = QString::number(engine.uncaughtExceptionLineNumber()); |
| 112 | 114 | engine.clearExceptions(); |
| 113 | 115 | |
| 114 | − auto message = QString("[UncaughtException] %1 in %2:%3").arg(exception, fileName, line); | |
| 116 | + auto message = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line); | |
| 115 | 117 | if (!backtrace.empty()) { |
| 116 | 118 | static const auto lineSeparator = "\n "; |
| 117 | 119 | message += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator)); |
| @@ -132,6 +134,13 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 14 unmodified lines | ||
| 132 | 134 | _allScriptsMutex.lock(); |
| 133 | 135 | _allKnownScriptEngines.insert(this); |
| 134 | 136 | _allScriptsMutex.unlock(); |
| 137 | + | |
| 138 | + connect(this, &QScriptEngine::signalHandlerException, this, [](const QScriptValue& exception) { | |
| 139 | + auto fileName = exception.property("fileName").toString(); | |
| 140 | + auto lineNumber = exception.property("lineNumber").toString(); | |
| 141 | + auto message = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception.toString(), fileName, lineNumber); | |
| 142 | + qCWarning(scriptengine) << qPrintable(message); | |
| 143 | + }); | |
| 135 | 144 | } |
| 136 | 145 | |
| 137 | 146 | ScriptEngine::~ScriptEngine() { |