public class

Throwables

extends java.lang.Object

 java.lang.Object

↳androidx.test.espresso.util.Throwables

Gradle dependencies

compile group: 'androidx.test.espresso', name: 'espresso-core', version: '3.6.1'

  • groupId: androidx.test.espresso
  • artifactId: espresso-core
  • version: 3.6.1

Artifact androidx.test.espresso:espresso-core:3.6.1 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.test.espresso:espresso-core com.android.support.test.espresso:espresso-core

Overview

Re-implementation of needed methods from Guava's Throwables to avoid the direct dependency

Summary

Methods
public static voidthrowIfUnchecked(java.lang.Throwable throwable)

Re-throw the exception if its a java.lang.RuntimeException or java.lang.Error.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public static void throwIfUnchecked(java.lang.Throwable throwable)

Re-throw the exception if its a java.lang.RuntimeException or java.lang.Error. Otherwise ignore.

Parameters:

throwable: the exception

Source

package androidx.test.espresso.util;

import static androidx.test.internal.util.Checks.checkNotNull;

import androidx.annotation.RestrictTo;

/**
 * Re-implementation of needed methods from Guava's Throwables to avoid the direct dependency
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class Throwables {

  private Throwables() {}

  /**
   * Re-throw the exception if its a {@link RuntimeException} or {@link Error}. Otherwise ignore.
   *
   * @param throwable the exception
   */
  public static void throwIfUnchecked(Throwable throwable) {
    checkNotNull(throwable);
    if (throwable instanceof RuntimeException) {
      throw (RuntimeException) throwable;
    }
    if (throwable instanceof Error) {
      throw (Error) throwable;
    }
  }
}