Android: Accept Throwables in Promise.reject()

Summary:
public

Fixes #4309

This adds the possibility to reject `Promise` instances with `Throwable`s in java, instead of strings.
For now, it only reads the message, but we can add more features on top of this, e.g. forwarding the error stack.

Reviewed By: andreicoman11

Differential Revision: D2708192

fb-gh-sync-id: ca5ff584eca29370a9f9b780fa9825b17863a7e9
This commit is contained in:
David Aurelio 2015-12-03 03:55:14 -08:00 committed by facebook-github-bot-4
parent 1a748f5ed6
commit a68c731aca
2 changed files with 6 additions and 0 deletions

View File

@ -18,5 +18,6 @@ package com.facebook.react.bridge;
*/ */
public interface Promise { public interface Promise {
void resolve(Object value); void resolve(Object value);
void reject(Throwable reason);
void reject(String reason); void reject(String reason);
} }

View File

@ -30,6 +30,11 @@ public class PromiseImpl implements Promise {
} }
} }
@Override
public void reject(Throwable reason) {
reject(reason.getMessage());
}
@Override @Override
public void reject(String reason) { public void reject(String reason) {
if (mReject != null) { if (mReject != null) {