# AppSearchException

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/exceptions/AppSearchException.java+class:androidx.appsearch.exceptions.AppSearchException) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
class AppSearchException : Exception
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html) |||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) ||
|   |   | ↳ | [androidx.appsearch.exceptions.AppSearchException](https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException) |

*** ** * ** ***

An exception thrown by `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession` or a subcomponent.

These exceptions can be converted into a failed `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult` for propagating to the client.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException#AppSearchException(int)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Initializes an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with no message. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException#AppSearchException(int,java.lang.String)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Initializes an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with a result code and message. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException#AppSearchException(int,java.lang.String,java.lang.Throwable)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, cause: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?)` Initializes an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with a result code, message and cause. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException#getResultCode()()` Returns the result code this exception was constructed with. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult<T!>` | `<T> https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException#toAppSearchResult()()` Converts this `https://developer.android.com/reference/java/lang/Exception.html` into a failed `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`. |

| ### Inherited functions |
|---|
| From [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) |---|---| | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/add-suppressed.html(exception: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/fill-in-stack-trace.html()` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-cause.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-localized-message.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-message.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/lang/StackTraceElement.html!>!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-stack-trace.html()` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!>!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/get-suppressed.html()` | | `synchronized https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/init-cause.html(cause: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/print-stack-trace.html()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/set-stack-trace.html(stackTrace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/lang/StackTraceElement.html!>!)` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/to-string.html()` | |

## Public constructors

### AppSearchException

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
AppSearchException(resultCode: Int)
```

Initializes an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with no message.

| Parameters |
|---|---|
| `resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One of the constants documented in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()`. |

### AppSearchException

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
AppSearchException(resultCode: Int, message: String?)
```

Initializes an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with a result code and message.

| Parameters |
|---|---|
| `resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One of the constants documented in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The detail message (which is saved for later retrieval by the `https://developer.android.com/reference/java/lang/Throwable.html#getMessage()` method). |

### AppSearchException

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
AppSearchException(resultCode: Int, message: String?, cause: Throwable?)
```

Initializes an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with a result code, message and cause.

| Parameters |
|---|---|
| `resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One of the constants documented in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The detail message (which is saved for later retrieval by the `https://developer.android.com/reference/java/lang/Throwable.html#getMessage()` method). |
| `cause: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?` | The cause (which is saved for later retrieval by the `https://developer.android.com/reference/java/lang/Throwable.html#getCause()` method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) |

## Public functions

### getResultCode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getResultCode(): Int
```

Returns the result code this exception was constructed with.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One of the constants documented in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()`. |

### toAppSearchResult

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun <T> toAppSearchResult(): AppSearchResult<T!>
```

Converts this `https://developer.android.com/reference/java/lang/Exception.html` into a failed `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`.