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

3 4
import com.google.firebase.crash.FirebaseCrash;

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

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