Package com.google.genai.errors
Class ApiException
-
- All Implemented Interfaces:
-
java.io.Serializable
public class ApiException extends BaseExceptionGeneral exception class for all exceptions originating from the GenAI API side.
-
-
Field Summary
Fields Modifier and Type Field Description public Throwablecausepublic Array<StackTraceElement>stackTrace
-
Constructor Summary
Constructors Constructor Description ApiException(int code, String status, String message)Creates a new ApiException with the specified code, status, and message.
-
Method Summary
Modifier and Type Method Description static voidthrowFromResponse(CloseableHttpResponse response)Throws an ApiException from the response if the response is not a OK status. static voidthrowFromResponse(Response response)Throws an ApiException from the response if the response is not a OK status. static voidthrowFromErrorNode(ArrayNode errorNode, int code)Throws an ApiException from a ArrayNode. intcode()Returns the status code from the API response. Stringstatus()Returns the status from the API response. Stringmessage()Returns the error message from the API response. -
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
throwFromResponse
@Deprecated() static void throwFromResponse(CloseableHttpResponse response)
Throws an ApiException from the response if the response is not a OK status.
- Parameters:
response- The response from the API call.
-
throwFromResponse
@InternalApi() static void throwFromResponse(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() static void throwFromErrorNode(ArrayNode errorNode, int code)
Throws an ApiException from a ArrayNode. This method is for internal use only.
-
code
int code()
Returns the status code from the API response.
-
-
-
-