LogIfError.java 714 Bytes
Newer Older
1 2
package chat.rocket.android.helper;

3
import com.crashlytics.android.Crashlytics;
4 5
import com.google.firebase.crash.FirebaseCrash;

6 7
import bolts.Continuation;
import bolts.Task;
8
import chat.rocket.android.BuildConfig;
Yusuke Iwaki's avatar
Yusuke Iwaki committed
9
import chat.rocket.android.log.RCLog;
10

11 12 13
/**
 * Bolts-Task continuation for just logging if error occurred.
 */
14
public class LogIfError implements Continuation {
15 16 17 18 19 20 21 22 23 24 25
    @Override
    public Object then(Task task) throws Exception {
        if (task.isFaulted()) {
            if (BuildConfig.DEBUG) {
                RCLog.w(task.getError());
            }

            FirebaseCrash.report(task.getError());
            Crashlytics.logException(task.getError());
        }
        return task;
26 27
    }
}