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
228 return message;228 return message;
229}229}
230 230
231std::shared_ptr<ScriptException> ScriptManager::getUncaughtException() const {
232 return _engine->uncaughtException();
233}
234
231ScriptManagerPointer scriptManagerFactory(ScriptManager::Context context,235ScriptManagerPointer scriptManagerFactory(ScriptManager::Context context,
232 const QString& scriptContents,236 const QString& scriptContents,
233 const QString& fileNameString) {237 const QString& fileNameString) {
@@ -303,6 +307,9 @@ ScriptManager::ScriptManager(Context context, const QString& scriptContents, con · 69 unmodified lines
303 });307 });
304#endif308#endif
305 309
310 // Forward exceptions from the scripting engine
311 connect(_engine.get(), &ScriptEngine::exception, this, &ScriptManager::unhandledException);
312
306 if (_type == Type::ENTITY_CLIENT || _type == Type::ENTITY_SERVER) {313 if (_type == Type::ENTITY_CLIENT || _type == Type::ENTITY_SERVER) {
307 QObject::connect(this, &ScriptManager::update, this, [this]() {314 QObject::connect(this, &ScriptManager::update, this, [this]() {
308 // process pending entity script content315 // process pending entity script content
@@ -902,7 +909,8 @@ void ScriptManager::run() { · 593 unmodified lines
902 909
903 qCWarning(scriptengine) << "Engine has uncaught exception, stopping";910 qCWarning(scriptengine) << "Engine has uncaught exception, stopping";
904 stop();911 stop();
905 _engine->clearExceptions();912 // V8TODO: Is clearing needed here?
913 //_engine->clearExceptions();
906 }914 }
907 }915 }
908#ifdef _WIN32916#ifdef _WIN32