Stay organized with collections
Save and categorize content based on your preferences.
InvocationTargetException
open class InvocationTargetException : ReflectiveOperationException
InvocationTargetException is a checked exception that wraps an exception thrown by an invoked method or constructor.
As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "target exception" that is provided at construction time and accessed via the getTargetException()
method is now known as the cause, and may be accessed via the Throwable.getCause()
method, as well as the aforementioned "legacy method."
Summary
Public constructors |
Constructs a InvocationTargetException with a target exception.
|
Constructs a InvocationTargetException with a target exception and a detail message.
|
Protected constructors |
Constructs an InvocationTargetException with null as the target exception.
|
Public methods |
open Throwable! |
Get the thrown target exception.
|
Properties |
open Throwable? |
Returns the cause of this exception (the thrown target exception, which may be null ).
|
Public constructors
InvocationTargetException
InvocationTargetException(target: Throwable!)
Constructs a InvocationTargetException with a target exception.
Parameters |
target |
Throwable!: the target exception |
InvocationTargetException
InvocationTargetException(
target: Throwable!,
s: String!)
Constructs a InvocationTargetException with a target exception and a detail message.
Parameters |
target |
Throwable!: the target exception |
s |
String!: the detail message |
Protected constructors
InvocationTargetException
protected InvocationTargetException()
Constructs an InvocationTargetException
with null
as the target exception.
Public methods
getTargetException
open fun getTargetException(): Throwable!
Get the thrown target exception.
This method predates the general-purpose exception chaining facility. The Throwable.getCause()
method is now the preferred means of obtaining this information.
Return |
Throwable! |
the thrown target exception (cause of this exception). |
Properties
cause
open val cause: Throwable?
Returns the cause of this exception (the thrown target exception, which may be null
).
Return |
Throwable? |
the cause of this exception. |
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,["# InvocationTargetException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nInvocationTargetException\n=========================\n\n```\nopen class InvocationTargetException : ReflectiveOperationException\n```\n\n|---|---|---|---|--------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) ||||\n| | ↳ | [java.lang.Exception](../Exception.html#) |||\n| | | ↳ | [java.lang.ReflectiveOperationException](../ReflectiveOperationException.html#) ||\n| | | | ↳ | [java.lang.reflect.InvocationTargetException](#) |\n\nInvocationTargetException is a checked exception that wraps an exception thrown by an invoked method or constructor.\n\nAs of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The \"target exception\" that is provided at construction time and accessed via the [getTargetException()](#getTargetException()) method is now known as the *cause* , and may be accessed via the [Throwable.getCause()](../Throwable.html#getCause()) method, as well as the aforementioned \"legacy method.\"\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [InvocationTargetException](#InvocationTargetException(kotlin.Throwable))`(`target:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`)` Constructs a InvocationTargetException with a target exception. |\n| [InvocationTargetException](#InvocationTargetException(kotlin.Throwable,%20kotlin.String))`(`target:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`, `s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs a InvocationTargetException with a target exception and a detail message. |\n\n| Protected constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [InvocationTargetException](#InvocationTargetException())`()` Constructs an `InvocationTargetException` with `null` as the target exception. |\n\n| Public methods ||\n|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|\n| open [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)! | [getTargetException](#getTargetException())`()` Get the thrown target exception. |\n\n| Properties ||\n|----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|\n| open [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)? | [cause](#cause:kotlin.Throwable) Returns the cause of this exception (the thrown target exception, which may be `null`). |\n\nPublic constructors\n-------------------\n\n### InvocationTargetException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nInvocationTargetException(target: Throwable!)\n```\n\nConstructs a InvocationTargetException with a target exception.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------|\n| `target` | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!: the target exception |\n\n### InvocationTargetException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nInvocationTargetException(\n target: Throwable!, \n s: String!)\n```\n\nConstructs a InvocationTargetException with a target exception and a detail message.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------|\n| `target` | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!: the target exception |\n| `s` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the detail message |\n\nProtected constructors\n----------------------\n\n### InvocationTargetException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nprotected InvocationTargetException()\n```\n\nConstructs an `InvocationTargetException` with `null` as the target exception.\n\nPublic methods\n--------------\n\n### getTargetException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getTargetException(): Throwable!\n```\n\nGet the thrown target exception.\n\nThis method predates the general-purpose exception chaining facility. The [Throwable.getCause()](../Throwable.html#getCause()) method is now the preferred means of obtaining this information.\n\n| Return ||\n|-----------------------------------------------------------------------------------------|--------------------------------------------------------|\n| [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)! | the thrown target exception (cause of this exception). |\n\nProperties\n----------\n\n### cause\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen val cause: Throwable?\n```\n\nReturns the cause of this exception (the thrown target exception, which may be `null`).\n\n| Return ||\n|-----------------------------------------------------------------------------------------|------------------------------|\n| [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)? | the cause of this exception. |"]]