Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -27,34 +27,13 @@ AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() { · 26 unmodified lines | ||
| 27 | 27 | _proxyModel.sort(0); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | −QString AssetMappingsScriptingInterface::getErrorString(int errorCode) const { | |
| 31 | − switch (errorCode) { | |
| 32 | − case MappingRequest::NoError: | |
| 33 | − return "No error"; | |
| 34 | − case MappingRequest::NotFound: | |
| 35 | − return "Asset not found"; | |
| 36 | − case MappingRequest::NetworkError: | |
| 37 | − return "Unable to communicate with Asset Server"; | |
| 38 | − case MappingRequest::PermissionDenied: | |
| 39 | − return "Permission denied"; | |
| 40 | − case MappingRequest::InvalidPath: | |
| 41 | − return "Path is invalid"; | |
| 42 | − case MappingRequest::InvalidHash: | |
| 43 | − return "Hash is invalid"; | |
| 44 | − case MappingRequest::UnknownError: | |
| 45 | − return "Asset Server internal error"; | |
| 46 | − default: | |
| 47 | − return QString(); | |
| 48 | − } | |
| 49 | −} | |
| 50 | − | |
| 51 | 30 | void AssetMappingsScriptingInterface::setMapping(QString path, QString hash, QJSValue callback) { |
| 52 | 31 | auto assetClient = DependencyManager::get<AssetClient>(); |
| 53 | 32 | auto request = assetClient->createSetMappingRequest(path, hash); |
| 54 | 33 | |
| 55 | 34 | connect(request, &SetMappingRequest::finished, this, [this, callback](SetMappingRequest* request) mutable { |
| 56 | 35 | if (callback.isCallable()) { |
| 57 | − QJSValueList args { uint8_t(request->getError()), request->getPath() }; | |
| 36 | + QJSValueList args { request->getErrorString(), request->getPath() }; | |
| 58 | 37 | callback.call(args); |
| 59 | 38 | } |
| 60 | 39 | |
| @@ -70,7 +49,7 @@ void AssetMappingsScriptingInterface::getMapping(QString path, QJSValue callback · 9 unmodified lines | ||
| 70 | 49 | |
| 71 | 50 | connect(request, &GetMappingRequest::finished, this, [this, callback](GetMappingRequest* request) mutable { |
| 72 | 51 | if (callback.isCallable()) { |
| 73 | − QJSValueList args { uint8_t(request->getError()) }; | |
| 52 | + QJSValueList args { request->getErrorString() }; | |
| 74 | 53 | callback.call(args); |
| 75 | 54 | } |
| 76 | 55 | |
| @@ -108,7 +87,7 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, · 31 unmodified lines | ||
| 108 | 87 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { |
| 109 | 88 | if (upload->getError() != AssetUpload::NoError) { |
| 110 | 89 | if (callback.isCallable()) { |
| 111 | − QJSValueList args { uint8_t(upload->getError()) }; | |
| 90 | + QJSValueList args { upload->getErrorString() }; | |
| 112 | 91 | callback.call(args); |
| 113 | 92 | } |
| 114 | 93 | } else { |
| @@ -127,7 +106,7 @@ void AssetMappingsScriptingInterface::deleteMappings(QStringList paths, QJSValue · 12 unmodified lines | ||
| 127 | 106 | |
| 128 | 107 | connect(request, &DeleteMappingsRequest::finished, this, [this, callback](DeleteMappingsRequest* request) mutable { |
| 129 | 108 | if (callback.isCallable()) { |
| 130 | − QJSValueList args { uint8_t(request->getError()) }; | |
| 109 | + QJSValueList args { request->getErrorString() }; | |
| 131 | 110 | callback.call(args); |
| 132 | 111 | } |
| 133 | 112 | |
| @@ -150,7 +129,7 @@ void AssetMappingsScriptingInterface::getAllMappings(QJSValue callback) { · 16 unmodified lines | ||
| 150 | 129 | } |
| 151 | 130 | |
| 152 | 131 | if (callback.isCallable()) { |
| 153 | − QJSValueList args { uint8_t(request->getError()), map }; | |
| 132 | + QJSValueList args { request->getErrorString(), map }; | |
| 154 | 133 | callback.call(args); |
| 155 | 134 | } |
| 156 | 135 | |
| @@ -166,7 +145,7 @@ void AssetMappingsScriptingInterface::renameMapping(QString oldPath, QString new · 9 unmodified lines | ||
| 166 | 145 | |
| 167 | 146 | connect(request, &RenameMappingRequest::finished, this, [this, callback](RenameMappingRequest* request) mutable { |
| 168 | 147 | if (callback.isCallable()) { |
| 169 | − QJSValueList args { uint8_t(request->getError()) }; | |
| 148 | + QJSValueList args { request->getErrorString() }; | |
| 170 | 149 | callback.call(args); |
| 171 | 150 | } |
| 172 | 151 | |
| @@ -293,7 +272,7 @@ void AssetMappingModel::refresh() { · 120 unmodified lines | ||
| 293 | 272 | } |
| 294 | 273 | } |
| 295 | 274 | } else { |
| 296 | − emit errorGettingMappings(static_cast<int>(request->getError())); | |
| 275 | + emit errorGettingMappings(request->getErrorString()); | |
| 297 | 276 | } |
| 298 | 277 | }); |
| 299 | 278 | |