# FailureHandler

Artifact: [androidx.test.espresso:espresso-core](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/FailureHandler.java+class:androidx.test.espresso.FailureHandler)

*** ** * ** ***


```
public interface FailureHandler
```

<br />

Known direct subclasses [DefaultFailureHandler](https://developer.android.com/reference/androidx/test/espresso/base/DefaultFailureHandler)

|---|---|
| `https://developer.android.com/reference/androidx/test/espresso/base/DefaultFailureHandler` | Espresso's default `https://developer.android.com/reference/androidx/test/espresso/FailureHandler`. |

*** ** * ** ***

Handles failures that happen during test execution.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/test/espresso/FailureHandler#handle(java.lang.Throwable,org.hamcrest.Matcher<android.view.View>)(https://developer.android.com/reference/java/lang/Throwable.html error, https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html> viewMatcher)` Handle the given error in a manner that makes sense to the environment in which the test is executed (e.g. take a screenshot, output extra debug info, etc). |

## Public methods

### handle

```
abstract void handle(Throwable error, Matcher<View> viewMatcher)
```

Handle the given error in a manner that makes sense to the environment in which the test is executed (e.g. take a screenshot, output extra debug info, etc). Upon handling, most handlers will choose to propagate the error.