From 54562afa96ab17a9471f0f117f28fc5ef131004a Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Thu, 21 Aug 2025 12:00:55 -0500 Subject: [PATCH 1/2] Make APINotConfiguredException adjustments --- .../com/google/firebase/ai/common/APIController.kt | 4 +++- .../com/google/firebase/ai/common/Exceptions.kt | 10 +++++----- .../com/google/firebase/ai/type/Exceptions.kt | 13 +++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt index 7ba9b026817..720b2c50a63 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt @@ -335,7 +335,9 @@ private suspend fun validateResponse(response: HttpResponse) { throw PromptBlockedException(message) } if (message.contains("genai config not found")) { - throw APINotConfiguredException() + throw APINotConfiguredException( + "The Gemini Developer API is not enabled, to enable and configure, see https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found" + ) } getServiceDisabledErrorDetailsOrNull(error)?.let { val errorMessage = diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt index cf90119e150..5201a6bb12f 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt @@ -90,14 +90,14 @@ internal class UnsupportedUserLocationException(cause: Throwable? = null) : FirebaseCommonAIException("User location is not supported for the API use.", cause) /** - * The user's project does not have the Gemini Developer API enabled in the Firebase Console. + * The user's project has not been configured and enabled for the selected API. * - * See the Firebase documentation for the + * For the Gemini Developer API, see * [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found) - * to enable the Gemini Developer API. + * . */ -internal class APINotConfiguredException(cause: Throwable? = null) : - FirebaseCommonAIException("Gemini Developer API not enabled in Firebase console.", cause) +internal class APINotConfiguredException(message: String, cause: Throwable? = null) : + FirebaseCommonAIException(message, cause) /** * Some form of state occurred that shouldn't have. diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt index 4118afd57c4..9d3823eec61 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt @@ -62,7 +62,7 @@ internal constructor(message: String, cause: Throwable? = null) : RuntimeExcepti is com.google.firebase.ai.common.QuotaExceededException -> QuotaExceededException(cause.message ?: "", cause.cause) is com.google.firebase.ai.common.APINotConfiguredException -> - APINotConfiguredException(cause.cause) + APINotConfiguredException(cause.message ?: "", cause.cause) else -> UnknownException(cause.message ?: "", cause) } is TimeoutCancellationException -> @@ -152,14 +152,15 @@ public class UnsupportedUserLocationException internal constructor(cause: Throwa FirebaseAIException("User location is not supported for the API use.", cause) /** - * The user's project does not have the Gemini Developer API enabled in the Firebase Console. + * The user's project has not been configured and enabled for the selected API. * - * See the Firebase documentation for the + * For the Gemini Developer API, see * [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found) - * to enable the Gemini Developer API. + * . */ -public class APINotConfiguredException internal constructor(cause: Throwable? = null) : - FirebaseAIException("Gemini Developer API not enabled in Firebase console.", cause) +public class APINotConfiguredException +internal constructor(message: String, cause: Throwable? = null) : + FirebaseAIException(message, cause) /** * Some form of state occurred that shouldn't have. From 85beeb13d7dcaa464d6f3ee45dcc2b8d63611add Mon Sep 17 00:00:00 2001 From: Emily Ploszaj Date: Thu, 21 Aug 2025 12:19:30 -0500 Subject: [PATCH 2/2] Formatting --- .../src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt | 1 - .../src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt index 5201a6bb12f..82ad80838f6 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt @@ -94,7 +94,6 @@ internal class UnsupportedUserLocationException(cause: Throwable? = null) : * * For the Gemini Developer API, see * [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found) - * . */ internal class APINotConfiguredException(message: String, cause: Throwable? = null) : FirebaseCommonAIException(message, cause) diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt index 9d3823eec61..a006f34e915 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt @@ -156,7 +156,6 @@ public class UnsupportedUserLocationException internal constructor(cause: Throwa * * For the Gemini Developer API, see * [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found) - * . */ public class APINotConfiguredException internal constructor(message: String, cause: Throwable? = null) :