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 коммит произвёл facebook-github-bot-4
Родитель 1a748f5ed6
Коммит a68c731aca
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

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

Просмотреть файл

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