@@ -20,19 +20,19 @@ import io.ktor.serialization.JsonConvertException
20
20
import kotlinx.coroutines.TimeoutCancellationException
21
21
22
22
/* * Parent class for any errors that occur. */
23
- internal sealed class GoogleGenerativeAIException (message : String , cause : Throwable ? = null ) :
23
+ internal sealed class FirebaseCommonAIException (message : String , cause : Throwable ? = null ) :
24
24
RuntimeException (message, cause) {
25
25
companion object {
26
26
27
27
/* *
28
- * Converts a [Throwable] to a [GoogleGenerativeAIException ].
28
+ * Converts a [Throwable] to a [FirebaseCommonAIException ].
29
29
*
30
30
* Will populate default messages as expected, and propagate the provided [cause] through the
31
31
* resulting exception.
32
32
*/
33
- fun from (cause : Throwable ): GoogleGenerativeAIException =
33
+ fun from (cause : Throwable ): FirebaseCommonAIException =
34
34
when (cause) {
35
- is GoogleGenerativeAIException -> cause
35
+ is FirebaseCommonAIException -> cause
36
36
is JsonConvertException ,
37
37
is kotlinx.serialization.SerializationException ->
38
38
SerializationException (
@@ -48,15 +48,15 @@ internal sealed class GoogleGenerativeAIException(message: String, cause: Throwa
48
48
49
49
/* * Something went wrong while trying to deserialize a response from the server. */
50
50
internal class SerializationException (message : String , cause : Throwable ? = null ) :
51
- GoogleGenerativeAIException (message, cause)
51
+ FirebaseCommonAIException (message, cause)
52
52
53
53
/* * The server responded with a non 200 response code. */
54
54
internal class ServerException (message : String , cause : Throwable ? = null ) :
55
- GoogleGenerativeAIException (message, cause)
55
+ FirebaseCommonAIException (message, cause)
56
56
57
57
/* * The server responded that the API Key is no valid. */
58
58
internal class InvalidAPIKeyException (message : String , cause : Throwable ? = null ) :
59
- GoogleGenerativeAIException (message, cause)
59
+ FirebaseCommonAIException (message, cause)
60
60
61
61
/* *
62
62
* A request was blocked for some reason.
@@ -69,7 +69,7 @@ internal class PromptBlockedException(
69
69
val response : GenerateContentResponse ,
70
70
cause : Throwable ? = null
71
71
) :
72
- GoogleGenerativeAIException (
72
+ FirebaseCommonAIException (
73
73
" Prompt was blocked: ${response.promptFeedback?.blockReason?.name} " ,
74
74
cause,
75
75
)
@@ -82,15 +82,15 @@ internal class PromptBlockedException(
82
82
* territories) where the API is available.
83
83
*/
84
84
internal class UnsupportedUserLocationException (cause : Throwable ? = null ) :
85
- GoogleGenerativeAIException (" User location is not supported for the API use." , cause)
85
+ FirebaseCommonAIException (" User location is not supported for the API use." , cause)
86
86
87
87
/* *
88
88
* Some form of state occurred that shouldn't have.
89
89
*
90
90
* Usually indicative of consumer error.
91
91
*/
92
92
internal class InvalidStateException (message : String , cause : Throwable ? = null ) :
93
- GoogleGenerativeAIException (message, cause)
93
+ FirebaseCommonAIException (message, cause)
94
94
95
95
/* *
96
96
* A request was stopped during generation for some reason.
@@ -101,7 +101,7 @@ internal class ResponseStoppedException(
101
101
val response : GenerateContentResponse ,
102
102
cause : Throwable ? = null
103
103
) :
104
- GoogleGenerativeAIException (
104
+ FirebaseCommonAIException (
105
105
" Content generation stopped. Reason: ${response.candidates?.first()?.finishReason?.name} " ,
106
106
cause,
107
107
)
@@ -112,16 +112,16 @@ internal class ResponseStoppedException(
112
112
* Usually occurs due to a user specified [timeout][RequestOptions.timeout].
113
113
*/
114
114
internal class RequestTimeoutException (message : String , cause : Throwable ? = null ) :
115
- GoogleGenerativeAIException (message, cause)
115
+ FirebaseCommonAIException (message, cause)
116
116
117
117
/* * The quota for this API key is depleted, retry this request at a later time. */
118
118
internal class QuotaExceededException (message : String , cause : Throwable ? = null ) :
119
- GoogleGenerativeAIException (message, cause)
119
+ FirebaseCommonAIException (message, cause)
120
120
121
121
/* * The service is not enabled for this project. Visit the Firebase Console to enable it. */
122
122
internal class ServiceDisabledException (message : String , cause : Throwable ? = null ) :
123
- GoogleGenerativeAIException (message, cause)
123
+ FirebaseCommonAIException (message, cause)
124
124
125
125
/* * Catch all case for exceptions not explicitly expected. */
126
126
internal class UnknownException (message : String , cause : Throwable ? = null ) :
127
- GoogleGenerativeAIException (message, cause)
127
+ FirebaseCommonAIException (message, cause)
0 commit comments