From 76cbc4ee55ec7349b19647b8eaba654b62444f44 Mon Sep 17 00:00:00 2001 From: humbletim Date: Tue, 23 Jan 2018 14:47:49 -0500 Subject: [PATCH] separate getAsset fail/then handlers --- libraries/script-engine/src/AssetScriptingInterface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/script-engine/src/AssetScriptingInterface.cpp b/libraries/script-engine/src/AssetScriptingInterface.cpp index 7c9bf2c4eb..78d0b323ee 100644 --- a/libraries/script-engine/src/AssetScriptingInterface.cpp +++ b/libraries/script-engine/src/AssetScriptingInterface.cpp @@ -236,11 +236,12 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope, Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback); Promise mapped = makePromise("mapped"); - mapped->ready([=](QString error, QVariantMap result) { + mapped->fail(fetched); + mapped->then([=](QVariantMap result) { QString hash = result.value("hash").toString(); QString url = result.value("url").toString(); - if (!error.isEmpty() || !AssetUtils::isValidHash(hash)) { - fetched->reject(error.isEmpty() ? "internal hash error: " + hash : error, result); + if (!AssetUtils::isValidHash(hash)) { + fetched->reject("internal hash error: " + hash, result); } else { Promise promise = loadAsset(hash, decompress, responseType); promise->mixin(result);