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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# FailureHandler\n\nSummary: [Methods](#pubmethods) \\| [\\[Expand All\\]](#) \n\nFailureHandler\n==============\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\n\n\ninterface\nFailureHandler\n`\n\n\n`\n\n\n`\n\n|----------------------------------------------|\n| android.support.test.espresso.FailureHandler |\n\n|---|---|\n| Known Indirect Subclasses [DefaultFailureHandler](/reference/android/support/test/espresso/base/DefaultFailureHandler) |----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| | [DefaultFailureHandler](/reference/android/support/test/espresso/base/DefaultFailureHandler) | Espresso's default [FailureHandler](/reference/android/support/test/espresso/FailureHandler). | ||\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nHandles failures that happen during test execution.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[handle](/reference/android/support/test/espresso/FailureHandler#handle(java.lang.Throwable, org.hamcrest.Matcher\u003candroid.view.View\u003e))`(`[Throwable](https://developer.android.com/reference/java/lang/Throwable.html)` error, Matcher\u003c`[View](https://developer.android.com/reference/android/view/View.html)`\u003e viewMatcher) ` Handle the given error in a manner that makes sense to the environment in which the test is executed (e.g. |\n\nPublic methods\n--------------\n\n### handle\n\n```\nvoid handle (Throwable error, \n Matcher\u003cView\u003e viewMatcher)\n```\n\nHandle the given error in a manner that makes sense to the environment in which the test is\nexecuted (e.g. take a screenshot, output extra debug info, etc). Upon handling, most handlers\nwill choose to propagate the error.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|--------------------|\n| `error` | `Throwable` \u003cbr /\u003e |\n| `viewMatcher` | `Matcher` \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [EspressoException](/reference/android/support/test/espresso/EspressoException)\n - [FailureHandler](/reference/android/support/test/espresso/FailureHandler)\n - [IdlingResource](/reference/android/support/test/espresso/IdlingResource)\n - [IdlingResource.ResourceCallback](/reference/android/support/test/espresso/IdlingResource.ResourceCallback)\n - [UiController](/reference/android/support/test/espresso/UiController)\n - [ViewAction](/reference/android/support/test/espresso/ViewAction)\n - [ViewAssertion](/reference/android/support/test/espresso/ViewAssertion)\n - [ViewFinder](/reference/android/support/test/espresso/ViewFinder)\n - [ViewInteractionComponent](/reference/android/support/test/espresso/ViewInteractionComponent)\n-\n\n Classes\n -------\n\n - [AmbiguousViewMatcherException.Builder](/reference/android/support/test/espresso/AmbiguousViewMatcherException.Builder)\n - [DataInteraction](/reference/android/support/test/espresso/DataInteraction)\n - [DataInteraction.DisplayDataMatcher](/reference/android/support/test/espresso/DataInteraction.DisplayDataMatcher)\n - [Espresso](/reference/android/support/test/espresso/Espresso)\n - [IdlingPolicies](/reference/android/support/test/espresso/IdlingPolicies)\n - [IdlingPolicy](/reference/android/support/test/espresso/IdlingPolicy)\n - [IdlingRegistry](/reference/android/support/test/espresso/IdlingRegistry)\n - [NoMatchingViewException.Builder](/reference/android/support/test/espresso/NoMatchingViewException.Builder)\n - [PerformException.Builder](/reference/android/support/test/espresso/PerformException.Builder)\n - [Root](/reference/android/support/test/espresso/Root)\n - [Root.Builder](/reference/android/support/test/espresso/Root.Builder)\n - [ViewInteraction](/reference/android/support/test/espresso/ViewInteraction)\n-\n\n Exceptions\n ----------\n\n - [AmbiguousViewMatcherException](/reference/android/support/test/espresso/AmbiguousViewMatcherException)\n - [AppNotIdleException](/reference/android/support/test/espresso/AppNotIdleException)\n - [IdlingResourceTimeoutException](/reference/android/support/test/espresso/IdlingResourceTimeoutException)\n - [InjectEventSecurityException](/reference/android/support/test/espresso/InjectEventSecurityException)\n - [NoActivityResumedException](/reference/android/support/test/espresso/NoActivityResumedException)\n - [NoMatchingRootException](/reference/android/support/test/espresso/NoMatchingRootException)\n - [NoMatchingViewException](/reference/android/support/test/espresso/NoMatchingViewException)\n - [PerformException](/reference/android/support/test/espresso/PerformException)"]]