[CredMan] Add the set of get-passkey exceptions.
Currently we only have create-passkey exception apis. This change
defines similar webauthn passkey exceptions for the get flow.
Bug: 271053017
Test: GetPublicKeyCredential*Exception(Java/Kt)Test
Relnote: "Added passkey get flow exceptions"
Change-Id: I4f65428a0b5427b09eb60a4b3d0dfb224624dd4b
diff --git a/credentials/credentials/api/current.txt b/credentials/credentials/api/current.txt
index 9db9e5e..88305ed 100644
--- a/credentials/credentials/api/current.txt
+++ b/credentials/credentials/api/current.txt
@@ -471,5 +471,15 @@
public class CreatePublicKeyCredentialException extends androidx.credentials.exceptions.CreateCredentialException {
}
+ public final class GetPublicKeyCredentialDomException extends androidx.credentials.exceptions.publickeycredential.GetPublicKeyCredentialException {
+ ctor public GetPublicKeyCredentialDomException(androidx.credentials.exceptions.domerrors.DomError domError, optional CharSequence? errorMessage);
+ ctor public GetPublicKeyCredentialDomException(androidx.credentials.exceptions.domerrors.DomError domError);
+ method public androidx.credentials.exceptions.domerrors.DomError getDomError();
+ property public final androidx.credentials.exceptions.domerrors.DomError domError;
+ }
+
+ public class GetPublicKeyCredentialException extends androidx.credentials.exceptions.GetCredentialException {
+ }
+
}
diff --git a/credentials/credentials/api/public_plus_experimental_current.txt b/credentials/credentials/api/public_plus_experimental_current.txt
index 9db9e5e..88305ed 100644
--- a/credentials/credentials/api/public_plus_experimental_current.txt
+++ b/credentials/credentials/api/public_plus_experimental_current.txt
@@ -471,5 +471,15 @@
public class CreatePublicKeyCredentialException extends androidx.credentials.exceptions.CreateCredentialException {
}
+ public final class GetPublicKeyCredentialDomException extends androidx.credentials.exceptions.publickeycredential.GetPublicKeyCredentialException {
+ ctor public GetPublicKeyCredentialDomException(androidx.credentials.exceptions.domerrors.DomError domError, optional CharSequence? errorMessage);
+ ctor public GetPublicKeyCredentialDomException(androidx.credentials.exceptions.domerrors.DomError domError);
+ method public androidx.credentials.exceptions.domerrors.DomError getDomError();
+ property public final androidx.credentials.exceptions.domerrors.DomError domError;
+ }
+
+ public class GetPublicKeyCredentialException extends androidx.credentials.exceptions.GetCredentialException {
+ }
+
}
diff --git a/credentials/credentials/api/restricted_current.txt b/credentials/credentials/api/restricted_current.txt
index 9db9e5e..88305ed 100644
--- a/credentials/credentials/api/restricted_current.txt
+++ b/credentials/credentials/api/restricted_current.txt
@@ -471,5 +471,15 @@
public class CreatePublicKeyCredentialException extends androidx.credentials.exceptions.CreateCredentialException {
}
+ public final class GetPublicKeyCredentialDomException extends androidx.credentials.exceptions.publickeycredential.GetPublicKeyCredentialException {
+ ctor public GetPublicKeyCredentialDomException(androidx.credentials.exceptions.domerrors.DomError domError, optional CharSequence? errorMessage);
+ ctor public GetPublicKeyCredentialDomException(androidx.credentials.exceptions.domerrors.DomError domError);
+ method public androidx.credentials.exceptions.domerrors.DomError getDomError();
+ property public final androidx.credentials.exceptions.domerrors.DomError domError;
+ }
+
+ public class GetPublicKeyCredentialException extends androidx.credentials.exceptions.GetCredentialException {
+ }
+
}
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
similarity index 93%
rename from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
rename to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
index fc094da..e782efc 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential;
+package androidx.credentials.exceptions.publickeycredential;
import static com.google.common.truth.Truth.assertThat;
import androidx.credentials.exceptions.domerrors.AbortError;
import androidx.credentials.exceptions.domerrors.DomError;
import androidx.credentials.exceptions.domerrors.EncodingError;
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialDomException;
import org.junit.Test;
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
similarity index 90%
rename from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
rename to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
index 75de88d..b8ae2bc 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential
+package androidx.credentials.exceptions.publickeycredential
import androidx.credentials.exceptions.domerrors.AbortError
import androidx.credentials.exceptions.domerrors.EncodingError
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialDomException
import com.google.common.truth.Truth
import org.junit.Test
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionJavaTest.java b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialExceptionJavaTest.java
similarity index 93%
rename from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionJavaTest.java
rename to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialExceptionJavaTest.java
index 7353cc3..b40128e 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionJavaTest.java
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialExceptionJavaTest.java
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential;
+package androidx.credentials.exceptions.publickeycredential;
import static com.google.common.truth.Truth.assertThat;
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialException;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionTest.kt b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialExceptionTest.kt
similarity index 91%
rename from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionTest.kt
rename to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialExceptionTest.kt
index 039b65b..5a2f1fe 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionTest.kt
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialExceptionTest.kt
@@ -14,9 +14,8 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential
+package androidx.credentials.exceptions.publickeycredential
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialException
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomExceptionJavaTest.java
similarity index 60%
copy from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
copy to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomExceptionJavaTest.java
index fc094da..561065f 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionJavaTest.java
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomExceptionJavaTest.java
@@ -14,36 +14,35 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential;
+package androidx.credentials.exceptions.publickeycredential;
import static com.google.common.truth.Truth.assertThat;
import androidx.credentials.exceptions.domerrors.AbortError;
import androidx.credentials.exceptions.domerrors.DomError;
import androidx.credentials.exceptions.domerrors.EncodingError;
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialDomException;
import org.junit.Test;
-public class CreatePublicKeyCredentialDomExceptionJavaTest {
+public class GetPublicKeyCredentialDomExceptionJavaTest {
- @Test(expected = CreatePublicKeyCredentialDomException.class)
+ @Test(expected = GetPublicKeyCredentialDomException.class)
public void construct_inputNonEmpty_success() throws
- CreatePublicKeyCredentialDomException {
- throw new CreatePublicKeyCredentialDomException(
+ GetPublicKeyCredentialDomException {
+ throw new GetPublicKeyCredentialDomException(
new AbortError(), "msg");
}
- @Test(expected = CreatePublicKeyCredentialDomException.class)
+ @Test(expected = GetPublicKeyCredentialDomException.class)
public void construct_errorMessageNull_success() throws
- CreatePublicKeyCredentialDomException {
- throw new CreatePublicKeyCredentialDomException(new
+ GetPublicKeyCredentialDomException {
+ throw new GetPublicKeyCredentialDomException(new
AbortError(), null);
}
@Test(expected = NullPointerException.class)
- public void construct_errorNull_failure() throws CreatePublicKeyCredentialDomException {
- throw new CreatePublicKeyCredentialDomException(null, "msg");
+ public void construct_errorNull_failure() throws GetPublicKeyCredentialDomException {
+ throw new GetPublicKeyCredentialDomException(null, "msg");
}
@Test
@@ -51,12 +50,12 @@
String expectedMessage = "msg";
DomError expectedDomError = new EncodingError();
String expectedType =
- CreatePublicKeyCredentialDomException
- .TYPE_CREATE_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION
+ GetPublicKeyCredentialDomException
+ .TYPE_GET_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION
+ expectedDomError.getType();
- CreatePublicKeyCredentialDomException exception = new
- CreatePublicKeyCredentialDomException(expectedDomError, expectedMessage);
+ GetPublicKeyCredentialDomException exception = new
+ GetPublicKeyCredentialDomException(expectedDomError, expectedMessage);
assertThat(exception.getType()).isEqualTo(expectedType);
assertThat(exception.getErrorMessage()).isEqualTo(expectedMessage);
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomExceptionTest.kt
similarity index 69%
copy from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
copy to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomExceptionTest.kt
index 75de88d..580e73e 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialDomExceptionTest.kt
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomExceptionTest.kt
@@ -14,18 +14,17 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential
+package androidx.credentials.exceptions.publickeycredential
import androidx.credentials.exceptions.domerrors.AbortError
import androidx.credentials.exceptions.domerrors.EncodingError
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialDomException
import com.google.common.truth.Truth
import org.junit.Test
-class CreatePublicKeyCredentialDomExceptionTest {
- @Test(expected = CreatePublicKeyCredentialDomException::class)
+class GetPublicKeyCredentialDomExceptionTest {
+ @Test(expected = GetPublicKeyCredentialDomException::class)
fun construct_inputNonEmpty_success() {
- throw CreatePublicKeyCredentialDomException(
+ throw GetPublicKeyCredentialDomException(
AbortError(), "msg"
)
}
@@ -35,10 +34,10 @@
val expectedMessage = "msg"
val expectedDomError = EncodingError()
val expectedType =
- CreatePublicKeyCredentialDomException.TYPE_CREATE_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION +
+ GetPublicKeyCredentialDomException.TYPE_GET_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION +
expectedDomError.type
- val exception = CreatePublicKeyCredentialDomException(expectedDomError, expectedMessage)
+ val exception = GetPublicKeyCredentialDomException(expectedDomError, expectedMessage)
Truth.assertThat(exception.type).isEqualTo(expectedType)
Truth.assertThat(exception.errorMessage).isEqualTo(expectedMessage)
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialExceptionJavaTest.java b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialExceptionJavaTest.java
new file mode 100644
index 0000000..919c35f
--- /dev/null
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialExceptionJavaTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.credentials.exceptions.publickeycredential;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class GetPublicKeyCredentialExceptionJavaTest {
+
+ @Test(expected = GetPublicKeyCredentialException.class)
+ public void construct_inputsNonEmpty_success() throws GetPublicKeyCredentialException {
+ throw new GetPublicKeyCredentialException("type", "msg");
+ }
+
+ @Test(expected = GetPublicKeyCredentialException.class)
+ public void construct_errorMessageNull_success() throws GetPublicKeyCredentialException {
+ throw new GetPublicKeyCredentialException("type", null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void construct_typeEmpty_throws() throws GetPublicKeyCredentialException {
+ throw new GetPublicKeyCredentialException("", "msg");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void construct_typeNull_throws() throws GetPublicKeyCredentialException {
+ throw new GetPublicKeyCredentialException(null, "msg");
+ }
+
+ @Test
+ public void getter_success() {
+ String expectedType = "type";
+ String expectedMessage = "message";
+ GetPublicKeyCredentialException exception = new
+ GetPublicKeyCredentialException(expectedType , expectedMessage);
+ assertThat(exception.getType()).isEqualTo(expectedType);
+ assertThat(exception.getErrorMessage()).isEqualTo(expectedMessage);
+ }
+}
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionTest.kt b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialExceptionTest.kt
similarity index 68%
copy from credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionTest.kt
copy to credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialExceptionTest.kt
index 039b65b..89c3756 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/createpublickeycredential/CreatePublicKeyCredentialExceptionTest.kt
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialExceptionTest.kt
@@ -14,9 +14,8 @@
* limitations under the License.
*/
-package androidx.credentials.exceptions.createpublickeycredential
+package androidx.credentials.exceptions.publickeycredential
-import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialException
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
@@ -25,28 +24,28 @@
@RunWith(AndroidJUnit4::class)
@SmallTest
-class CreatePublicKeyCredentialExceptionTest {
+class GetPublicKeyCredentialExceptionTest {
- @Test(expected = CreatePublicKeyCredentialException::class)
+ @Test(expected = GetPublicKeyCredentialException::class)
fun construct_inputsNonEmpty_success() {
- throw CreatePublicKeyCredentialException("type", "msg")
+ throw GetPublicKeyCredentialException("type", "msg")
}
- @Test(expected = CreatePublicKeyCredentialException::class)
+ @Test(expected = GetPublicKeyCredentialException::class)
fun construct_errorMessageNull_success() {
- throw CreatePublicKeyCredentialException("type", null)
+ throw GetPublicKeyCredentialException("type", null)
}
@Test(expected = IllegalArgumentException::class)
fun construct_typeEmpty_throws() {
- throw CreatePublicKeyCredentialException("", "msg")
+ throw GetPublicKeyCredentialException("", "msg")
}
@Test
fun getter_success() {
val expectedType = "type"
val expectedMessage = "message"
- val exception = CreatePublicKeyCredentialException(expectedType, expectedMessage)
+ val exception = GetPublicKeyCredentialException(expectedType, expectedMessage)
assertThat(exception.type).isEqualTo(expectedType)
assertThat(exception.errorMessage).isEqualTo(expectedMessage)
}
diff --git a/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomException.kt b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomException.kt
index cb2c092..3a5a0f1c 100644
--- a/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomException.kt
+++ b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialDomException.kt
@@ -17,22 +17,17 @@
package androidx.credentials.exceptions.publickeycredential
import androidx.annotation.VisibleForTesting
-import androidx.credentials.exceptions.domerrors.AbortError
import androidx.credentials.exceptions.domerrors.DomError
/**
- * During the create public key credential flow, this is thrown when a DOM Exception is thrown,
+ * During the create-passkey flow, this is thrown when a DOM Exception is thrown,
* indicating the operation contains a DOMException error type. The fido spec can be found
- * [here](https://webidl.spec.whatwg.org/#idl-DOMException-error-names). To see the full list of
- * implemented DOMErrors, please see the API docs associated with this package. For example, one
- * such error is [AbortError].
+ * [here](https://webidl.spec.whatwg.org/#idl-DOMException-error-names). The full list of
+ * implemented DOMErrors extends from and can be seen at [DomError].
*
* @property domError the specific error from the DOMException types defined in the fido spec found
* [here](https://webidl.spec.whatwg.org/#idl-DOMException-error-names)
* @throws NullPointerException If [domError] is null
- *
- * @see CreatePublicKeyCredentialException
- *
*/
class CreatePublicKeyCredentialDomException @JvmOverloads constructor(
val domError: DomError,
diff --git a/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialException.kt b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialException.kt
index 8c0a040..bfcc858 100644
--- a/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialException.kt
+++ b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/CreatePublicKeyCredentialException.kt
@@ -23,11 +23,7 @@
/**
* A subclass of CreateCredentialException for unique exceptions thrown specific only to
* PublicKeyCredentials. See [CredentialManager] for more details on how Credentials work for
- * Credential Manager flows. See [GMS Error Codes](https://developers.google.com/android/reference/com/google/android/gms/fido/fido2/api/common/ErrorCode)
- * for more details on some of the subclasses.
- *
- * @see CredentialManager
- * @see CreatePublicKeyCredentialDomException
+ * Credential Manager flows.
*
* @throws NullPointerException if [type] is null
* @throws IllegalArgumentException if [type] is empty
diff --git a/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomException.kt b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomException.kt
new file mode 100644
index 0000000..08eb797
--- /dev/null
+++ b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialDomException.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.credentials.exceptions.publickeycredential
+
+import androidx.annotation.VisibleForTesting
+import androidx.credentials.exceptions.domerrors.DomError
+
+/**
+ * During the get-passkey flow, this is thrown when a DOM Exception is thrown,
+ * indicating the operation contains a DOMException error type. The fido spec can be found
+ * [here](https://webidl.spec.whatwg.org/#idl-DOMException-error-names). The full list of
+ * implemented DOMErrors extends from and can be seen at [DomError].
+ *
+ * @property domError the specific error from the DOMException types defined in the fido spec found
+ * [here](https://webidl.spec.whatwg.org/#idl-DOMException-error-names)
+ * @throws NullPointerException If [domError] is null
+ */
+class GetPublicKeyCredentialDomException @JvmOverloads constructor(
+ val domError: DomError,
+ errorMessage: CharSequence? = null
+) : GetPublicKeyCredentialException(
+ TYPE_GET_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION + domError.type,
+ errorMessage) {
+ /** @hide */
+ companion object {
+ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
+ const val TYPE_GET_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION: String =
+ "androidx.credentials.TYPE_GET_PUBLIC_KEY_CREDENTIAL_DOM_EXCEPTION"
+ }
+}
\ No newline at end of file
diff --git a/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialException.kt b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialException.kt
new file mode 100644
index 0000000..ca1eb692
--- /dev/null
+++ b/credentials/credentials/src/main/java/androidx/credentials/exceptions/publickeycredential/GetPublicKeyCredentialException.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.credentials.exceptions.publickeycredential
+
+import androidx.annotation.RestrictTo
+import androidx.credentials.CredentialManager
+import androidx.credentials.exceptions.GetCredentialException
+
+/**
+ * A subclass of CreateCredentialException for unique exceptions thrown specific only to
+ * PublicKeyCredentials. See [CredentialManager] for more details on how Credentials work for
+ * Credential Manager flows.
+ *
+ * @throws NullPointerException if [type] is null
+ * @throws IllegalArgumentException if [type] is empty
+ */
+open class GetPublicKeyCredentialException @JvmOverloads internal constructor(
+ /** @hide */
+ @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+ override val type: String,
+ errorMessage: CharSequence? = null
+) : GetCredentialException(type, errorMessage) {
+ init {
+ require(type.isNotEmpty()) { "type must not be empty" }
+ }
+}
\ No newline at end of file