mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 04:42:20 +02:00
Allow accessing engine exceptions from ScriptManager
This commit is contained in:
parent
de02da5fda
commit
bb74c2ecc9
2 changed files with 17 additions and 1 deletions
|
@ -228,6 +228,10 @@ QString ScriptManager::logException(const ScriptValue& exception) {
|
|||
return message;
|
||||
}
|
||||
|
||||
std::shared_ptr<ScriptException> ScriptManager::getUncaughtException() const {
|
||||
return _engine->uncaughtException();
|
||||
}
|
||||
|
||||
ScriptManagerPointer scriptManagerFactory(ScriptManager::Context context,
|
||||
const QString& scriptContents,
|
||||
const QString& fileNameString) {
|
||||
|
@ -303,6 +307,9 @@ ScriptManager::ScriptManager(Context context, const QString& scriptContents, con
|
|||
});
|
||||
#endif
|
||||
|
||||
// Forward exceptions from the scripting engine
|
||||
connect(_engine.get(), &ScriptEngine::exception, this, &ScriptManager::unhandledException);
|
||||
|
||||
if (_type == Type::ENTITY_CLIENT || _type == Type::ENTITY_SERVER) {
|
||||
QObject::connect(this, &ScriptManager::update, this, [this]() {
|
||||
// process pending entity script content
|
||||
|
@ -902,7 +909,8 @@ void ScriptManager::run() {
|
|||
|
||||
qCWarning(scriptengine) << "Engine has uncaught exception, stopping";
|
||||
stop();
|
||||
_engine->clearExceptions();
|
||||
// V8TODO: Is clearing needed here?
|
||||
//_engine->clearExceptions();
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -1172,6 +1172,14 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString& path);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the uncaught exception from the underlying script engine
|
||||
*
|
||||
* @return std::shared_ptr<ScriptException> Exception
|
||||
*/
|
||||
std::shared_ptr<ScriptException> getUncaughtException() const;
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue