History

Merge pull request #7600 from sethalves/fix-entity-script-error-message

attempt to make the failed-to-load-entity-script error-message be more helpful

Brad Hefta-Gaub committed 10 years ago

Commit ce1625b2 parents 94e797d 672b4df1 file · +13 −3Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+13−3
@@ -1124,9 +1124,19 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 1123 unmodified lines
11241124 }
11251125
11261126 if (!testConstructor.isFunction()) {
1127− qCDebug(scriptengine) << "ScriptEngine::loadEntityScript() entity:" << entityID << "\n"
1128− " NOT CONSTRUCTOR\n"
1129− " SCRIPT:" << scriptOrURL;
1127+ QString testConstructorType = QString(testConstructor.toVariant().typeName());
1128+ if (testConstructorType == "") {
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;
11301140
11311141 if (!isFileUrl) {
11321142 scriptCache->addScriptToBadScriptList(scriptOrURL);