Skip to content

Commit

Permalink
Reject promise when if an error occurs while processing prefetching r…
Browse files Browse the repository at this point in the history
…esult

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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 29, 2020
1 parent 78d2b3c commit e9f29a3
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

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;
Expand Down Expand Up @@ -58,6 +59,7 @@ public ImageLoaderModule(ReactApplicationContext reactContext, Object callerCont
}

@Override
@NonNull
public String getName() {
return NAME;
}
Expand Down Expand Up @@ -212,6 +214,8 @@ protected void onNewResultImpl(DataSource<Void> dataSource) {
try {
removeRequest(requestId);
promise.resolve(true);
} catch (Exception e) {
promise.reject(ERROR_PREFETCH_FAILURE, e);
} finally {
dataSource.close();
}
Expand Down

0 comments on commit e9f29a3

Please sign in to comment.