com.google.android.gms.tasks.RuntimeExecutionException Java Examples

The following examples show how to use com.google.android.gms.tasks.RuntimeExecutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StorageTask.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the result of the Task, if it has already completed.
 *
 * @throws IllegalStateException if the Task is not yet complete
 * @throws X if the Task failed with an exception of type X
 * @throws RuntimeExecutionException if the Task failed with an exception that was not of type X
 */
@NonNull
@Override
public <X extends Throwable> ResultT getResult(@NonNull Class<X> exceptionType) throws X {
  if (getFinalResult() == null) {
    throw new IllegalStateException();
  }
  if (exceptionType.isInstance(getFinalResult().getError())) {
    throw exceptionType.cast(getFinalResult().getError());
  }
  Throwable t = getFinalResult().getError();
  if (t != null) {
    throw new RuntimeExecutionException(t);
  }
  return getFinalResult();
}
 
Example #2
Source File: StorageTask.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the result of the Task, if it has already completed.
 *
 * @throws IllegalStateException if the Task is not yet complete
 * @throws RuntimeExecutionException if the Task failed with an exception
 */
@NonNull
@Override
public ResultT getResult() {
  if (getFinalResult() == null) {
    throw new IllegalStateException();
  }
  Throwable t = getFinalResult().getError();
  if (t != null) {
    throw new RuntimeExecutionException(t);
  }
  return getFinalResult();
}
 
Example #3
Source File: AutoCompleteTask.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
@Override
public TResult getResult() {
    if (mSuccess) {
        return mResult;
    } else {
        throw new RuntimeExecutionException(mException);
    }
}
 
Example #4
Source File: AutoCompleteTask.java    From FirebaseUI-Android with Apache License 2.0 4 votes vote down vote up
private static Exception unwrap(Exception e) {
    if (e instanceof RuntimeExecutionException && e.getCause() instanceof Exception) {
        return (Exception) e.getCause();
    }
    return e;
}