Reject promise when if an error occurs while processing prefetching result

Summary:
This diff rejects the promise when if an error occurs while processing prefetching result, it applies the same concept as other methods in this class (e.g. see getSizeWithHeaders)

changelog: [internal][Android] Internal change in RN Image prefetching

Reviewed By: JoshuaGross

Differential Revision: D21295612

fbshipit-source-id: c3675e5f2d9c8e38094a538b388ff63a6ea18360
This commit is contained in:
David Vacca
2020-04-28 21:44:23 -07:00
committed by Facebook GitHub Bot
parent 78d2b3c813
commit e9f29a3291
@@ -9,6 +9,7 @@ package com.facebook.react.modules.image;
import android.net.Uri;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.references.CloseableReference;
@@ -58,6 +59,7 @@ public class ImageLoaderModule extends NativeImageLoaderAndroidSpec
}
@Override
@NonNull
public String getName() {
return NAME;
}
@@ -212,6 +214,8 @@ public class ImageLoaderModule extends NativeImageLoaderAndroidSpec
try {
removeRequest(requestId);
promise.resolve(true);
} catch (Exception e) {
promise.reject(ERROR_PREFETCH_FAILURE, e);
} finally {
dataSource.close();
}