Package com.google.genai.errors
Class ApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.google.genai.errors.ApiException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ClientException
,ServerException
General exception class for all exceptions originating from the GenAI API side.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionApiException
(int code, String status, String message) Creates a new ApiException with the specified code, status, and message. -
Method Summary
Modifier and TypeMethodDescriptionint
code()
Returns the status code from the API response.message()
Returns the error message from the API response.status()
Returns the status from the API response.static void
throwFromErrorNode
(com.fasterxml.jackson.databind.node.ArrayNode errorNode, int code) Throws an ApiException from aArrayNode
.static void
throwFromResponse
(okhttp3.Response response) Throws an ApiException from the response if the response is not a OK status.static void
throwFromResponse
(org.apache.http.client.methods.CloseableHttpResponse response) Deprecated.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ApiException
Creates a new ApiException with the specified code, status, and message.- Parameters:
code
- The status code from the API response.status
- The status from the API response.message
- The error message from the API response.
-
-
Method Details
-
throwFromResponse
@Deprecated public static void throwFromResponse(org.apache.http.client.methods.CloseableHttpResponse response) Deprecated.UsethrowFromResponse(Response)
instead.Throws an ApiException from the response if the response is not a OK status.- Parameters:
response
- The response from the API call.
-
throwFromResponse
@InternalApi public static void throwFromResponse(okhttp3.Response response) Throws an ApiException from the response if the response is not a OK status.- Parameters:
response
- The response from the API call.
-
throwFromErrorNode
@InternalApi public static void throwFromErrorNode(com.fasterxml.jackson.databind.node.ArrayNode errorNode, int code) Throws an ApiException from aArrayNode
. This method is for internal use only. -
code
public int code()Returns the status code from the API response. -
status
Returns the status from the API response. -
message
Returns the error message from the API response.
-
throwFromResponse(Response)
instead.