diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 017ffd94f1..a7927fd5b4 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -27,6 +27,7 @@ #include "NodeType.h" #include "SendAssetTask.h" #include "UploadAssetTask.h" +#include const QString ASSET_SERVER_LOGGING_TARGET_NAME = "asset-server"; diff --git a/assignment-client/src/assets/SendAssetTask.cpp b/assignment-client/src/assets/SendAssetTask.cpp index d2b3c6c256..ca8733d660 100644 --- a/assignment-client/src/assets/SendAssetTask.cpp +++ b/assignment-client/src/assets/SendAssetTask.cpp @@ -21,6 +21,7 @@ #include #include "AssetUtils.h" +#include "ClientServerUtils.h" SendAssetTask::SendAssetTask(QSharedPointer message, const SharedNodePointer& sendToNode, const QDir& resourcesDir) : QRunnable(), diff --git a/assignment-client/src/assets/UploadAssetTask.cpp b/assignment-client/src/assets/UploadAssetTask.cpp index e09619a3cc..7e8e94c34d 100644 --- a/assignment-client/src/assets/UploadAssetTask.cpp +++ b/assignment-client/src/assets/UploadAssetTask.cpp @@ -18,6 +18,8 @@ #include #include +#include "ClientServerUtils.h" + UploadAssetTask::UploadAssetTask(QSharedPointer receivedMessage, SharedNodePointer senderNode, const QDir& resourcesDir) : diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index ca48016feb..c1e53dda17 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -11,8 +11,6 @@ #include "EntityScriptServer.h" -#include "EntityScriptUtils.h" - #include #include #include @@ -26,6 +24,7 @@ #include #include +#include "ClientServerUtils.h" #include "../entities/AssignmentParentFinder.h" int EntityScriptServer::_entitiesScriptEngineCount = 0; diff --git a/libraries/networking/src/AssetClient.h b/libraries/networking/src/AssetClient.h index be1cafa232..c0d58cd8e6 100644 --- a/libraries/networking/src/AssetClient.h +++ b/libraries/networking/src/AssetClient.h @@ -21,6 +21,7 @@ #include #include "AssetUtils.h" +#include "ClientServerUtils.h" #include "LimitedNodeList.h" #include "Node.h" #include "ReceivedMessage.h" diff --git a/libraries/networking/src/AssetUtils.h b/libraries/networking/src/AssetUtils.h index b0008271d2..4137193274 100644 --- a/libraries/networking/src/AssetUtils.h +++ b/libraries/networking/src/AssetUtils.h @@ -19,7 +19,6 @@ #include #include -using MessageID = uint32_t; using DataOffset = int64_t; using AssetPath = QString; @@ -27,8 +26,6 @@ using AssetHash = QString; using AssetMapping = std::map; using AssetPathList = QStringList; -const MessageID INVALID_MESSAGE_ID = 0; - const size_t SHA256_HASH_LENGTH = 32; const size_t SHA256_HASH_HEX_LENGTH = 64; const uint64_t MAX_UPLOAD_SIZE = 1000 * 1000 * 1000; // 1GB @@ -66,4 +63,4 @@ bool isValidFilePath(const AssetPath& path); bool isValidPath(const AssetPath& path); bool isValidHash(const QString& hashString); -#endif +#endif // hifi_AssetUtils_h diff --git a/libraries/networking/src/ClientServerUtils.h b/libraries/networking/src/ClientServerUtils.h new file mode 100644 index 0000000000..234c6d7c91 --- /dev/null +++ b/libraries/networking/src/ClientServerUtils.h @@ -0,0 +1,21 @@ + +// +// ClientServerUtils.h +// libraries/networking/src +// +// Created by Ryan Huffman on 2017/01/20 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ClientServerUtils_h +#define hifi_ClientServerUtils_h + +#include + +using MessageID = uint32_t; +const MessageID INVALID_MESSAGE_ID = 0; + +#endif // hifi_ClientServerUtils_h diff --git a/libraries/networking/src/EntityScriptClient.h b/libraries/networking/src/EntityScriptClient.h index d331b8ca31..926521d9b8 100644 --- a/libraries/networking/src/EntityScriptClient.h +++ b/libraries/networking/src/EntityScriptClient.h @@ -12,6 +12,7 @@ #ifndef hifi_EntityScriptClient_h #define hifi_EntityScriptClient_h +#include "ClientServerUtils.h" #include "LimitedNodeList.h" #include "ReceivedMessage.h" #include "AssetUtils.h" @@ -20,8 +21,6 @@ #include #include -using MessageID = uint32_t; - using GetScriptStatusCallback = std::function; class GetScriptStatusRequest : public QObject { diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index c6b5f2c174..ab9d4af417 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -147,19 +147,22 @@ static bool hasCorrectSyntax(const QScriptProgram& program, ScriptEngine* report return true; } -static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString& exceptionMessage = QString()) { +static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString* exceptionMessage = nullptr) { if (engine.hasUncaughtException()) { const auto backtrace = engine.uncaughtExceptionBacktrace(); const auto exception = engine.uncaughtException().toString(); const auto line = QString::number(engine.uncaughtExceptionLineNumber()); engine.clearExceptions(); - exceptionMessage = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line); + QString message = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line); if (!backtrace.empty()) { static const auto lineSeparator = "\n "; - exceptionMessage += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator)); + message += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator)); + } + reportingEngine->scriptErrorMessage(qPrintable(message)); + if (exceptionMessage) { + *exceptionMessage = message; } - reportingEngine->scriptErrorMessage(qPrintable(exceptionMessage)); return true; } return false; @@ -1471,7 +1474,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co } QString exceptionMessage; - if (hadUncaughtExceptions(sandbox, program.fileName(), this, exceptionMessage)) { + if (hadUncaughtExceptions(sandbox, program.fileName(), this, &exceptionMessage)) { newDetails.status = ERROR_RUNNING_SCRIPT; newDetails.errorInfo = exceptionMessage; _entityScripts[entityID] = newDetails;