# 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)

*** ** * ** ***


```
public class AppSearchException extends Exception
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [kotlin.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) |||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) ||
|   |   | ↳ | [androidx.appsearch.exceptions.AppSearchException](https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException) |

*** ** * ** ***

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

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException#AppSearchException(int)(int resultCode)` Initializes an `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException` with no message. |
| `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException#AppSearchException(int,java.lang.String)(int resultCode, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html message)` Initializes an `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException` with a result code and message. |
| `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException#AppSearchException(int,java.lang.String,java.lang.Throwable)( int resultCode, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html cause )` Initializes an `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException` with a result code, message and cause. |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException#getResultCode()()` Returns the result code this exception was constructed with. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<T>` | `<T> https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException#toAppSearchResult()()` Converts this `https://developer.android.com/reference/java/lang/Exception.html` into a failed `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult`. |

### Inherited methods

From [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable.html) `synchronized final void` `https://developer.android.com/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable.html exception)` `synchronized https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#fillInStackTrace()()` `synchronized https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#getCause()()` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#getLocalizedMessage()()` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#getMessage()()` `StackTraceElement[]` `https://developer.android.com/reference/java/lang/Throwable.html#getStackTrace()()` `synchronized final Throwable[]` `https://developer.android.com/reference/java/lang/Throwable.html#getSuppressed()()` `synchronized https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#initCause(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable.html cause)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#printStackTrace()()` `void` `https://developer.android.com/reference/java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[])(StackTraceElement[] stackTrace)` `https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/java/lang/Throwable.html#toString()()`

## Public constructors

### AppSearchException

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

```
public AppSearchException(int resultCode)
```

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

| Parameters |
|---|---|
| `int resultCode` | One of the constants documented in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()`. |

### AppSearchException

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

```
public AppSearchException(int resultCode, @Nullable String message)
```

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

| Parameters |
|---|---|
| `int resultCode` | One of the constants documented in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html message` | 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)

```
public AppSearchException(
    int resultCode,
    @Nullable String message,
    @Nullable Throwable cause
)
```

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

| Parameters |
|---|---|
| `int resultCode` | One of the constants documented in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html message` | The detail message (which is saved for later retrieval by the `https://developer.android.com/reference/java/lang/Throwable.html#getMessage()` method). |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html cause` | 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 methods

### getResultCode

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

```
public int getResultCode()
```

Returns the result code this exception was constructed with.

| Returns |
|---|---|
| `int` | One of the constants documented in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#getResultCode()`. |

### toAppSearchResult

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

```
public @NonNull AppSearchResult<T> <T> toAppSearchResult()
```

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