GenAiException

public class GenAiException extends Exception


Represents an exception that occurs during service execution.

Summary

Public methods

int

Gets the ErrorCode.

@NonNull Duration

Returns the Duration to wait before trying again, or Duration.ZERO if not known/not applicable.

Inherited methods

From java.lang.Throwable
synchronized final void
synchronized Throwable
synchronized Throwable
String
String
StackTraceElement[]
synchronized final Throwable[]
synchronized Throwable
void
void
setStackTrace(StackTraceElement[] p)
String

Public fields

errorCode

@GenAiException.ErrorCode
public final int errorCode

retryDelay

public final @NonNull Duration retryDelay

Public methods

getErrorCode

@GenAiException.ErrorCode
public int getErrorCode()

Gets the ErrorCode.

getRetryDelay

public @NonNull Duration getRetryDelay()

Returns the Duration to wait before trying again, or Duration.ZERO if not known/not applicable.

For requests to the ML Kit GenAI API that exceed quota, this is the amount of time to wait before trying the request again. For other requests, this value is Duration.ZERO.