History

Allow accessing engine exceptions from ScriptManager

Dale Glass committed 3 years ago

Commit bb74c2e1 parent de02da52 files · +17 −1Browse files

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

Unified · Split

libraries/script-engine/src/ScriptManager.cpp+9−1
@@ -228,6 +228,10 @@ QString ScriptManager::logException(const ScriptValue& exception) { · 227 unmodified lines
228228 return message;
229229 }
230230
231+std::shared_ptr<ScriptException> ScriptManager::getUncaughtException() const {
232+ return _engine->uncaughtException();
233+}
234+
231235 ScriptManagerPointer scriptManagerFactory(ScriptManager::Context context,
232236 const QString& scriptContents,
233237 const QString& fileNameString) {
@@ -303,6 +307,9 @@ ScriptManager::ScriptManager(Context context, const QString& scriptContents, con · 69 unmodified lines
303307 });
304308 #endif
305309
310+ // Forward exceptions from the scripting engine
311+ connect(_engine.get(), &ScriptEngine::exception, this, &ScriptManager::unhandledException);
312+
306313 if (_type == Type::ENTITY_CLIENT || _type == Type::ENTITY_SERVER) {
307314 QObject::connect(this, &ScriptManager::update, this, [this]() {
308315 // process pending entity script content
@@ -902,7 +909,8 @@ void ScriptManager::run() { · 593 unmodified lines
902909
903910 qCWarning(scriptengine) << "Engine has uncaught exception, stopping";
904911 stop();
905− _engine->clearExceptions();
912+ // V8TODO: Is clearing needed here?
913+ //_engine->clearExceptions();
906914 }
907915 }
908916 #ifdef _WIN32