Skip to content

Commit 0e88e83

Browse files
committed
Make APINotConfiguredException adjustments (#7284)
1 parent e9ee7a4 commit 0e88e83

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ private suspend fun validateResponse(response: HttpResponse) {
335335
throw PromptBlockedException(message)
336336
}
337337
if (message.contains("genai config not found")) {
338-
throw APINotConfiguredException()
338+
throw APINotConfiguredException(
339+
"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"
340+
)
339341
}
340342
getServiceDisabledErrorDetailsOrNull(error)?.let {
341343
val errorMessage =

firebase-ai/src/main/kotlin/com/google/firebase/ai/common/Exceptions.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,13 @@ internal class UnsupportedUserLocationException(cause: Throwable? = null) :
9090
FirebaseCommonAIException("User location is not supported for the API use.", cause)
9191

9292
/**
93-
* The user's project does not have the Gemini Developer API enabled in the Firebase Console.
93+
* The user's project has not been configured and enabled for the selected API.
9494
*
95-
* See the Firebase documentation for the
95+
* For the Gemini Developer API, see
9696
* [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found)
97-
* to enable the Gemini Developer API.
9897
*/
99-
internal class APINotConfiguredException(cause: Throwable? = null) :
100-
FirebaseCommonAIException("Gemini Developer API not enabled in Firebase console.", cause)
98+
internal class APINotConfiguredException(message: String, cause: Throwable? = null) :
99+
FirebaseCommonAIException(message, cause)
101100

102101
/**
103102
* Some form of state occurred that shouldn't have.

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Exceptions.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal constructor(message: String, cause: Throwable? = null) : RuntimeExcepti
6262
is com.google.firebase.ai.common.QuotaExceededException ->
6363
QuotaExceededException(cause.message ?: "", cause.cause)
6464
is com.google.firebase.ai.common.APINotConfiguredException ->
65-
APINotConfiguredException(cause.cause)
65+
APINotConfiguredException(cause.message ?: "", cause.cause)
6666
else -> UnknownException(cause.message ?: "", cause)
6767
}
6868
is TimeoutCancellationException ->
@@ -152,14 +152,14 @@ public class UnsupportedUserLocationException internal constructor(cause: Throwa
152152
FirebaseAIException("User location is not supported for the API use.", cause)
153153

154154
/**
155-
* The user's project does not have the Gemini Developer API enabled in the Firebase Console.
155+
* The user's project has not been configured and enabled for the selected API.
156156
*
157-
* See the Firebase documentation for the
157+
* For the Gemini Developer API, see
158158
* [steps](https://firebase.google.com/docs/ai-logic/faq-and-troubleshooting?api=dev#error-genai-config-not-found)
159-
* to enable the Gemini Developer API.
160159
*/
161-
public class APINotConfiguredException internal constructor(cause: Throwable? = null) :
162-
FirebaseAIException("Gemini Developer API not enabled in Firebase console.", cause)
160+
public class APINotConfiguredException
161+
internal constructor(message: String, cause: Throwable? = null) :
162+
FirebaseAIException(message, cause)
163163

164164
/**
165165
* Some form of state occurred that shouldn't have.

0 commit comments

Comments
 (0)