History

Cleanup and better error handling

Liv committed 9 years ago

Commit 33402111 parent e9fac381 file · +4 −6Browse 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+4−6
@@ -428,10 +428,7 @@ QString ScriptEngine::getFilename() const { · 427 unmodified lines
428428 bool ScriptEngine::hasValidScriptSuffix(const QString& scriptFileName) {
429429 QFileInfo fileInfo(scriptFileName);
430430 QString scriptSuffixToLower = fileInfo.completeSuffix().toLower();
431− if (scriptSuffixToLower == "js" || scriptSuffixToLower == "json") {
432− return true;
433− }
434− return false;
431+ return ((scriptSuffixToLower == "js") || (scriptSuffixToLower == "json"));
435432 }
436433
437434 void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
@@ -443,9 +440,10 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { · 5 unmodified lines
443440 _fileNameString = url.toString();
444441 _isReloading = reload;
445442
446− // Check that script is an actual script
443+ // Check that script has a supported file extension
447444 if (!hasValidScriptSuffix(_fileNameString)) {
448− qCDebug(scriptengine) << "File extension of file: " + _fileNameString + " is not a currently supported script type";
445+ scriptErrorMessage("File extension of file: " + _fileNameString + " is not a currently supported script type");
446+ emit errorLoadingScript(_fileNameString);
449447 return;
450448 }
451449