fix asset loading with error changes

This commit is contained in:
Stephen Birarda 2016-03-10 11:58:55 -08:00
parent 9c53f40fbe
commit 50a05df721
3 changed files with 18 additions and 24 deletions

View file

@ -482,7 +482,7 @@ void AssetServer::loadMappingsFromFile() {
}
}
qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment with not continue.";
qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment will not continue.";
setFinished(true);
} else {
qInfo() << "No existing mappings loaded from file since no file was found at" << mapFilePath;

View file

@ -37,7 +37,7 @@ void AssetRequest::start() {
}
// in case we haven't parsed a valid hash, return an error now
if (isValidHash(_hash)) {
if (!isValidHash(_hash)) {
_error = InvalidHash;
_state = Finished;
@ -62,7 +62,7 @@ void AssetRequest::start() {
auto assetClient = DependencyManager::get<AssetClient>();
assetClient->getAssetInfo(_hash, [this](bool responseReceived, AssetServerError serverError, AssetInfo info) {
_info = info;
if (!responseReceived) {
_error = NetworkError;
} else if (serverError != AssetServerError::NoError) {

View file

@ -58,15 +58,6 @@ void AssetResourceRequest::requestMappingForPath(const AssetPath& path) {
auto assetClient = DependencyManager::get<AssetClient>();
_assetMappingRequest = assetClient->createGetMappingRequest(path);
// if we get a nullptr for createGetMappingRequest assume that there is no currently available asset-server
if (!_assetMappingRequest) {
_result = ServerUnavailable;
_state = Finished;
emit finished();
return;
}
// make sure we'll hear about the result of the get mapping request
connect(_assetMappingRequest, &GetMappingRequest::finished, this, [this, path](GetMappingRequest* request){
Q_ASSERT(_state == InProgress);
@ -80,24 +71,27 @@ void AssetResourceRequest::requestMappingForPath(const AssetPath& path) {
requestHash(request->getHash());
break;
case MappingRequest::NotFound:
// no result for the mapping request, set error to not found
_result = NotFound;
default: {
switch (request->getError()) {
case MappingRequest::NotFound:
// no result for the mapping request, set error to not found
_result = NotFound;
break;
case MappingRequest::NetworkError:
// didn't hear back from the server, mark it unavailable
_result = ServerUnavailable;
break;
default:
_result = Error;
break;
}
// since we've failed we know we are finished
_state = Finished;
emit finished();
break;
default:
// these are unexpected errors for a GetMappingRequest object
_result = Error;
// since we've failed we know we are finished
_state = Finished;
emit finished();
break;
}
}
_assetMappingRequest->deleteLater();