attempt to make the failed-to-load-entity-script error-message be more helpful
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1124,9 +1124,19 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 1123 unmodified lines | |||
| 1124 | } | 1124 | } |
| 1125 | 1125 | ||
| 1126 | if (!testConstructor.isFunction()) { | 1126 | if (!testConstructor.isFunction()) { |
| 1127 | qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID << "\n" | 1127 | QString testConstructorType = QString(testConstructor.toVariant().typeName()); |
| 1128 | " NOT CONSTRUCTOR\n" | 1128 | if (testConstructorType == "") { |
| 1129 | " SCRIPT:" << scriptOrURL; | 1129 | testConstructorType = "empty"; |
| 1130 | } | ||
| 1131 | QString testConstructorValue = testConstructor.toString(); | ||
| 1132 | const int maxTestConstructorValueSize = 80; | ||
| 1133 | if (testConstructorValue.size() > maxTestConstructorValueSize) { | ||
| 1134 | testConstructorValue = testConstructorValue.mid(0, maxTestConstructorValueSize) + "..."; | ||
| 1135 | } | ||
| 1136 | qCDebug(scriptengine) << "Error -- ScriptEngine::loadEntityScript() entity:" << entityID | ||
| 1137 | << "failed to load entity script -- expected a function, got " + testConstructorType | ||
| 1138 | << "," << testConstructorValue | ||
| 1139 | << "," << scriptOrURL; | ||
| 1130 | 1140 | ||
| 1131 | if (!isFileUrl) { | 1141 | if (!isFileUrl) { |
| 1132 | scriptCache->addScriptToBadScriptList(scriptOrURL); | 1142 | scriptCache->addScriptToBadScriptList(scriptOrURL); |