# CreateCredentialException

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/exceptions/CreateCredentialException.kt+class:androidx.credentials.exceptions.CreateCredentialException) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***


```
public abstract class CreateCredentialException 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.credentials.exceptions.CreateCredentialException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException) |

Known direct subclasses [CreateCredentialCancellationException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialCancellationException), [CreateCredentialCustomException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialCustomException), [CreateCredentialInterruptedException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialInterruptedException), [CreateCredentialNoCreateOptionException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialNoCreateOptionException), [CreateCredentialProviderConfigurationException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialProviderConfigurationException), [CreateCredentialUnknownException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialUnknownException), [CreateCredentialUnsupportedException](https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialUnsupportedException), [CreatePublicKeyCredentialException](https://developer.android.com/reference/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialException), [CreateRestoreCredentialDomException](https://developer.android.com/reference/androidx/credentials/exceptions/restorecredential/CreateRestoreCredentialDomException), [E2eeUnavailableException](https://developer.android.com/reference/androidx/credentials/exceptions/restorecredential/E2eeUnavailableException)

|---|---|
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialCancellationException` | During the create credential flow, this is thrown when a user intentionally cancels an operation. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialCustomException` | Represents a custom error thrown during a create flow with `https://developer.android.com/reference/androidx/credentials/CredentialManager`. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialInterruptedException` | During the create credential flow, this is thrown when some interruption occurs that may warrant retrying or at least does not indicate a purposeful desire to close or tap away from credential manager. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialNoCreateOptionException` | During the create credential flow, this is thrown when no viable creation options were found for the given `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest`. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialProviderConfigurationException` | During the create credential flow, this is thrown when configurations are mismatched for the provider, typically indicating the provider dependency is missing in the manifest or some system service is not enabled. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialUnknownException` | This is thrown when the create credential operation failed with no more detailed information. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialUnsupportedException` | During the create credential flow, this is thrown when credential manager is unsupported, typically because the device has disabled it or did not ship with this feature enabled. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialException` | A subclass of CreateCredentialException for unique exceptions thrown specific only to PublicKeyCredentials. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/restorecredential/CreateRestoreCredentialDomException` | During the create restore credential flow, this is thrown when a DOM Exception is thrown, indicating the operation contains a DOMException error type. |
| `https://developer.android.com/reference/androidx/credentials/exceptions/restorecredential/E2eeUnavailableException` | During the Restore Credential creation, this is thrown when the developer requests backup to cloud but the user device did not enable end-to-end-encryption or backup. |

Known indirect subclasses [CreatePublicKeyCredentialDomException](https://developer.android.com/reference/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomException)

|---|---|
| `https://developer.android.com/reference/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomException` | During the create-passkey flow, this is thrown when a DOM Exception is thrown, indicating the operation contains a DOMException error type. |

*** ** * ** ***

Represents an error thrown during a create flow with Credential Manager. See `https://developer.android.com/reference/androidx/credentials/CredentialManager` for more details on how Exceptions work for Credential Manager flows.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/credentials/CredentialManager` |   |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialInterruptedException` |   |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialCancellationException` |   |
| `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialUnknownException` |   |

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException#asBundle(androidx.credentials.exceptions.CreateCredentialException)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException ex)` Helper method to convert the given `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException.Companion#asBundle(androidx.credentials.exceptions.CreateCredentialException)` to a parcelable `https://developer.android.com/reference/android/os/Bundle.html`, in case the instance needs to be sent across a process. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException` | `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException#fromBundle(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html bundle)` Helper method to convert a `https://developer.android.com/reference/android/os/Bundle.html` retrieved through `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException#asBundle(androidx.credentials.exceptions.CreateCredentialException)`, back to an instance of `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException`. |

### Inherited methods

From [kotlin.Throwable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html) `final void` `https://developer.android.com/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html exception)` `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#fillInStackTrace()()` `https://developer.android.com/reference/java/lang/Throwable.html` `https://developer.android.com/reference/java/lang/Throwable.html#getCause()()` `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `@https://developer.android.com/reference/androidx/annotation/RecentlyNullable
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()()` `@https://developer.android.com/reference/androidx/annotation/NonNull StackTraceElement[]` `@https://developer.android.com/reference/androidx/annotation/RecentlyNonNull
https://developer.android.com/reference/java/lang/Throwable.html#getStackTrace()()` `final @https://developer.android.com/reference/androidx/annotation/NonNull Throwable[]` `@https://developer.android.com/reference/androidx/annotation/RecentlyNonNull
https://developer.android.com/reference/java/lang/Throwable.html#getSuppressed()()` `@https://developer.android.com/reference/androidx/annotation/NonNull 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/androidx/annotation/NonNull 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#printStackTrace(java.io.PrintStream)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/PrintStream.html s)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintWriter)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/PrintWriter.html s)` `void` `https://developer.android.com/reference/java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[])(@https://developer.android.com/reference/androidx/annotation/NonNull StackTraceElement[] stackTrace)`

## Public methods

### asBundle

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

```
public static final @NonNull Bundle asBundle(@NonNull CreateCredentialException ex)
```

Helper method to convert the given `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException.Companion#asBundle(androidx.credentials.exceptions.CreateCredentialException)` to a parcelable `https://developer.android.com/reference/android/os/Bundle.html`, in case the instance needs to be sent across a process. Consumers of this method should use `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException#fromBundle(android.os.Bundle)` to reconstruct the class instance back from the bundle returned here.

### fromBundle

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

```
public static final @NonNull CreateCredentialException fromBundle(@NonNull Bundle bundle)
```

Helper method to convert a `https://developer.android.com/reference/android/os/Bundle.html` retrieved through `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException#asBundle(androidx.credentials.exceptions.CreateCredentialException)`, back to an instance of `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException`.

Throws `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` if the conversion fails. This means that the given `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException.Companion#fromBundle(android.os.Bundle)` does not contain a `CreateCredentialException`. The bundle should be constructed and retrieved from `https://developer.android.com/reference/androidx/credentials/exceptions/CreateCredentialException#asBundle(androidx.credentials.exceptions.CreateCredentialException)` itself and never be created from scratch to avoid the failure.