History

Further exception work on V8

* Get rid of maybeEmitUncaughtException * Mostly get rid of makeError * Introduce exception hierarchy, change exceptions to shared_ptr * Simplify exception throwing code

Dale Glass committed 3 years ago

Commit 67e7a731 parent c0e62c510 files · +249 −260Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 10 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+10−12
@@ -132,7 +132,7 @@ void EntityScriptingInterface::releaseEntityPacketSenderMessages(bool wait) { · 131 unmodified lines
132132 void EntityScriptingInterface::attachDefaultEventHandlers(ScriptManager* manager) {
133133 // Connect up ALL the handlers to the global entities object's signals.
134134 // (We could go signal by signal, or even handler by handler, but I don't think the efficiency is worth the complexity.)
135−
135+
136136 // Bug? These handlers are deleted when entityID is deleted, which is nice.
137137 // But if they are created by an entity script on a different entity, should they also be deleted when the entity script unloads?
138138 // E.g., suppose a bow has an entity script that causes arrows to be created with a potential lifetime greater than the bow,
@@ -194,7 +194,7 @@ void EntityScriptingInterface::attachDefaultEventHandlers(ScriptManager* manager · 55 unmodified lines
194194 };
195195
196196 /*@jsdoc
197− * <p>The name of an entity event. When the entity event occurs, any function that has been registered for that event
197+ * <p>The name of an entity event. When the entity event occurs, any function that has been registered for that event
198198 * via {@link Script.addEventHandler} is called with parameters per the entity event.</p>
199199 * <table>
200200 * <thead>
@@ -782,7 +782,7 @@ QUuid EntityScriptingInterface::cloneEntity(const QUuid& entityIDToClone) { · 581 unmodified lines
782782 } else if (cloneAvatarEntity) {
783783 return addEntityInternal(properties, entity::HostType::AVATAR);
784784 } else {
785− // setLastEdited timestamp to 0 to ensure this entity gets updated with the properties
785+ // setLastEdited timestamp to 0 to ensure this entity gets updated with the properties
786786 // from the server-created entity, don't change this unless you know what you are doing
787787 properties.setLastEdited(0);
788788 bool success = addLocalEntityCopy(properties, newEntityID, true);
@@ -1255,7 +1255,7 @@ void EntityScriptingInterface::setNonPersistentEntitiesScriptEngine(std::shared_ · 466 unmodified lines
12551255
12561256 void EntityScriptingInterface::callEntityMethod(const QUuid& id, const QString& method, const QStringList& params) {
12571257 PROFILE_RANGE(script_entities, __FUNCTION__);
1258−
1258+
12591259 auto entity = getEntityTree()->findEntityByEntityItemID(id);
12601260 if (entity) {
12611261 std::lock_guard<std::recursive_mutex> lock(_entitiesScriptEngineLock);
@@ -1605,7 +1605,7 @@ bool EntityScriptingInterface::queryPropertyMetadata(const QUuid& entityID, · 343 unmodified lines
16051605 #endif
16061606 if (!handler.property("callback").isFunction()) {
16071607 qDebug() << "!handler.callback.isFunction" << manager;
1608− engine->raiseException(engine->makeError(engine->newValue("callback is not a function"), "TypeError"));
1608+ engine->raiseException("callback is not a function", "TypeError");
16091609 return false;
16101610 }
16111611
@@ -1628,8 +1628,7 @@ bool EntityScriptingInterface::queryPropertyMetadata(const QUuid& entityID, · 16 unmodified lines
16281628 } else if (name == "serverScripts") {
16291629 return request.serverScripts(entityID, handler);
16301630 } else {
1631− engine->raiseException(engine->makeError(engine->newValue("metadata for property " + name + " is not yet queryable")));
1632− engine->maybeEmitUncaughtException(__FUNCTION__);
1631+ engine->raiseException("metadata for property " + name + " is not yet queryable");
16331632 return false;
16341633 }
16351634 }
@@ -1644,8 +1643,7 @@ bool EntityScriptingInterface::getServerScriptStatus(const QUuid& entityID, Scri · 8 unmodified lines
16441643 Q_ASSERT(QThread::currentThread() == engine->thread());
16451644 Q_ASSERT(QThread::currentThread() == engine->manager()->thread());
16461645 if (!manager) {
1647− engine->raiseException(engine->makeError(engine->newValue("This script does not belong to a ScriptManager")));
1648− engine->maybeEmitUncaughtException(__FUNCTION__);
1646+ engine->raiseException("This script does not belong to a ScriptManager");
16491647 return false;
16501648 }
16511649
@@ -2015,17 +2013,17 @@ EntityItemPointer EntityScriptingInterface::checkForTreeEntityAndTypeMatch(const · 363 unmodified lines
20152013 if (!_entityTree) {
20162014 return EntityItemPointer();
20172015 }
2018−
2016+
20192017 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
20202018 if (!entity) {
20212019 qCDebug(entities) << "EntityScriptingInterface::checkForTreeEntityAndTypeMatch - no entity with ID" << entityID;
20222020 return entity;
20232021 }
2024−
2022+
20252023 if (entityType != EntityTypes::Unknown && entity->getType() != entityType) {
20262024 return EntityItemPointer();
20272025 }
2028−
2026+
20292027 return entity;
20302028 }
20312029