public class **GenAiException** extends [Exception](https://developer.android.com/reference/java/lang/Exception.html)  
Represents an exception that occurs during service execution.

### Nested Class Summary

|---|---|---|---|
| @interface | [GenAiException.ErrorCode](https://developers.google.com/android/reference/com/google/mlkit/genai/common/GenAiException.ErrorCode) || The set of error codes. |

### Public Method Summary

|---|---|
| int | [getErrorCode](https://developers.google.com/android/reference/com/google/mlkit/genai/common/GenAiException#getErrorCode())() Gets the `https://developers.google.com/android/reference/com/google/mlkit/genai/common/GenAiException.ErrorCode`. |
| [Duration](https://developer.android.com/reference/java/time/Duration.html) | [getRetryDelay](https://developers.google.com/android/reference/com/google/mlkit/genai/common/GenAiException#getRetryDelay())() Returns the `https://developer.android.com/reference/java/time/Duration.html` to wait before trying again, or `Duration.ZERO` if not known/not applicable. |

### Inherited Method Summary

From class java.lang.Throwable

|---|---|
| synchronized final void | addSuppressed([Throwable](https://developer.android.com/reference/java/lang/Throwable.html) arg0) |
| synchronized [Throwable](https://developer.android.com/reference/java/lang/Throwable.html) | fillInStackTrace() |
| synchronized [Throwable](https://developer.android.com/reference/java/lang/Throwable.html) | getCause() |
| [String](https://developer.android.com/reference/java/lang/String.html) | getLocalizedMessage() |
| [String](https://developer.android.com/reference/java/lang/String.html) | getMessage() |
| [StackTraceElement\[\]](https://developer.android.com/reference/java/lang/StackTraceElement.html) | getStackTrace() |
| synchronized final [Throwable\[\]](https://developer.android.com/reference/java/lang/Throwable.html) | getSuppressed() |
| synchronized [Throwable](https://developer.android.com/reference/java/lang/Throwable.html) | initCause([Throwable](https://developer.android.com/reference/java/lang/Throwable.html) arg0) |
| void | printStackTrace() |
| void | printStackTrace([PrintWriter](https://developer.android.com/reference/java/io/PrintWriter.html) arg0) |
| void | printStackTrace([PrintStream](https://developer.android.com/reference/java/io/PrintStream.html) arg0) |
| void | setStackTrace([StackTraceElement\[\]](https://developer.android.com/reference/java/lang/StackTraceElement.html) arg0) |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public int **getErrorCode** ()

Gets the `https://developers.google.com/android/reference/com/google/mlkit/genai/common/GenAiException.ErrorCode`.

#### public [Duration](https://developer.android.com/reference/java/time/Duration.html)
**getRetryDelay** ()

Returns the `https://developer.android.com/reference/java/time/Duration.html` 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`.