# MlKitException

public class **MlKitException** extends [Exception](https://developer.android.com/reference/java/lang/Exception.html)  
Represents an exception thrown by ML Kit.

### Nested Class Summary

|---|---|---|---|
| @interface | [MlKitException.ErrorCode](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException.ErrorCode) || The set of ML Kit status codes. |

### Constant Summary

|---|---|---|
| int | [ABORTED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#ABORTED) | The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. |
| int | [ALREADY_EXISTS](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#ALREADY_EXISTS) | Some resource that we attempted to create already exists. |
| int | [CANCELLED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CANCELLED) | The operation was cancelled (typically by the caller). |
| int | [CODE_SCANNER_APP_NAME_UNAVAILABLE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_APP_NAME_UNAVAILABLE) | Not able to get the calling App name. |
| int | [CODE_SCANNER_CAMERA_PERMISSION_NOT_GRANTED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_CAMERA_PERMISSION_NOT_GRANTED) | Camera permission is not granted to Google Play Service. |
| int | [CODE_SCANNER_CANCELLED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_CANCELLED) | User closes the scanner to cancel code scanning. |
| int | [CODE_SCANNER_GOOGLE_PLAY_SERVICES_VERSION_TOO_OLD](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_GOOGLE_PLAY_SERVICES_VERSION_TOO_OLD) | Google play services version is too old. |
| int | [CODE_SCANNER_PIPELINE_INFERENCE_ERROR](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_PIPELINE_INFERENCE_ERROR) | Failed to run the inference of barcode detection. |
| int | [CODE_SCANNER_PIPELINE_INITIALIZATION_ERROR](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_PIPELINE_INITIALIZATION_ERROR) | Failed to initialize barcode scanner pipeline. |
| int | [CODE_SCANNER_TASK_IN_PROGRESS](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_TASK_IN_PROGRESS) | At most one scanning task is allowed to be in progress. |
| int | [CODE_SCANNER_UNAVAILABLE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#CODE_SCANNER_UNAVAILABLE) | Required code scanner module is not available yet. |
| int | [DATA_LOSS](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#DATA_LOSS) | Unrecoverable data loss or corruption. |
| int | [DEADLINE_EXCEEDED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#DEADLINE_EXCEEDED) | Deadline expired before operation could complete. |
| int | [FAILED_PRECONDITION](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#FAILED_PRECONDITION) | Operation was rejected because the system is not in a state required for the operation's execution. |
| int | [INTERNAL](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#INTERNAL) | Internal errors. |
| int | [INVALID_ARGUMENT](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#INVALID_ARGUMENT) | Client specified an invalid argument. |
| int | [MODEL_HASH_MISMATCH](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#MODEL_HASH_MISMATCH) | The downloaded model's hash doesn't match the expected value. |
| int | [MODEL_INCOMPATIBLE_WITH_TFLITE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#MODEL_INCOMPATIBLE_WITH_TFLITE) | The downloaded model isn't compatible with the TFLite runtime. |
| int | [NETWORK_ISSUE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#NETWORK_ISSUE) | There is a network issue when filing a network request. |
| int | [NOT_ENOUGH_SPACE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#NOT_ENOUGH_SPACE) | There is not enough space left on the device. |
| int | [NOT_FOUND](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#NOT_FOUND) | Some requested resource was not found. |
| int | [OUT_OF_RANGE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#OUT_OF_RANGE) | Operation was attempted past the valid range. |
| int | [PERMISSION_DENIED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#PERMISSION_DENIED) | The caller does not have permission to execute the specified operation. |
| int | [RESOURCE_EXHAUSTED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#RESOURCE_EXHAUSTED) | Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. |
| int | [UNAUTHENTICATED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#UNAUTHENTICATED) | The request does not have valid authentication credentials for the operation. |
| int | [UNAVAILABLE](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#UNAVAILABLE) | The service is currently unavailable. |
| int | [UNIMPLEMENTED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#UNIMPLEMENTED) | Operation is not implemented or not supported/enabled. |
| int | [UNKNOWN](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#UNKNOWN) | Unknown error or an error from a different error domain. |
| int | [UNSUPPORTED](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#UNSUPPORTED) | The feature is not supported on this device. |

### Public Method Summary

|---|---|
| int | [getErrorCode](https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#getErrorCode())() Gets the error code for the ML Kit operation that failed. |

### 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() |

## Constants

#### public static final int
**ABORTED**

The operation was aborted, typically due to a concurrency issue like transaction
aborts, etc.
Constant Value: 10

#### public static final int
**ALREADY_EXISTS**

Some resource that we attempted to create already exists.
Constant Value: 6

#### public static final int
**CANCELLED**

The operation was cancelled (typically by the caller).
Constant Value: 1

#### public static final int
**CODE_SCANNER_APP_NAME_UNAVAILABLE**

Not able to get the calling App name.
Constant Value: 203

#### public static final int
**CODE_SCANNER_CAMERA_PERMISSION_NOT_GRANTED**

Camera permission is not granted to Google Play Service.
Constant Value: 202

#### public static final int
**CODE_SCANNER_CANCELLED**

User closes the scanner to cancel code scanning.
Constant Value: 201

#### public static final int
**CODE_SCANNER_GOOGLE_PLAY_SERVICES_VERSION_TOO_OLD**

Google play services version is too old.
Constant Value: 207

#### public static final int
**CODE_SCANNER_PIPELINE_INFERENCE_ERROR**

Failed to run the inference of barcode detection.
Constant Value: 206

#### public static final int
**CODE_SCANNER_PIPELINE_INITIALIZATION_ERROR**

Failed to initialize barcode scanner pipeline.
Constant Value: 205

#### public static final int
**CODE_SCANNER_TASK_IN_PROGRESS**

At most one scanning task is allowed to be in progress.
Constant Value: 204

#### public static final int
**CODE_SCANNER_UNAVAILABLE**

Required code scanner module is not available yet.
Constant Value: 200

#### public static final int
**DATA_LOSS**

Unrecoverable data loss or corruption.
Constant Value: 15

#### public static final int
**DEADLINE_EXCEEDED**

Deadline expired before operation could complete. For operations that change the
state of the system, this error may be returned even if the operation has completed
successfully. For example, a successful response from a server could have been delayed
long enough for the deadline to expire.
Constant Value: 4

#### public static final int
**FAILED_PRECONDITION**

Operation was rejected because the system is not in a state required for the
operation's execution.
Constant Value: 9

#### public static final int
**INTERNAL**

Internal errors. Means some invariants expected by underlying system has been
broken. If you see one of these errors, something is very broken.
Constant Value: 13

#### public static final int
**INVALID_ARGUMENT**

Client specified an invalid argument. Note that this differs from `https://developers.google.com/android/reference/com/google/mlkit/common/MlKitException#FAILED_PRECONDITION`.
INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of
the system (e.g., an invalid field name).
Constant Value: 3

#### public static final int
**MODEL_HASH_MISMATCH**

The downloaded model's hash doesn't match the expected value.
Constant Value: 102

#### public static final int
**MODEL_INCOMPATIBLE_WITH_TFLITE**

The downloaded model isn't compatible with the TFLite runtime.
Constant Value: 100

#### public static final int
**NETWORK_ISSUE**

There is a network issue when filing a network request.
Constant Value: 17

#### public static final int
**NOT_ENOUGH_SPACE**

There is not enough space left on the device.
Constant Value: 101

#### public static final int
**NOT_FOUND**

Some requested resource was not found.
Constant Value: 5

#### public static final int
**OUT_OF_RANGE**

Operation was attempted past the valid range.
Constant Value: 11

#### public static final int
**PERMISSION_DENIED**

The caller does not have permission to execute the specified operation.
Constant Value: 7

#### public static final int
**RESOURCE_EXHAUSTED**

Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire
file system is out of space.
Constant Value: 8

#### public static final int
**UNAUTHENTICATED**

The request does not have valid authentication credentials for the operation.
Constant Value: 16

#### public static final int
**UNAVAILABLE**

The service is currently unavailable.

In ML Kit, this error is mostly caused by one of the following reasons: 1. The
models being not available yet: This is a most likely a transient condition and may be
corrected by retrying with a backoff. 2. The remote server is not available when trying
to connect to it. 3. The detector/scanner has already been closed: This usually
indicates that detector is called after lifecycle event "ON_DESTROY".
Constant Value: 14

#### public static final int
**UNIMPLEMENTED**

Operation is not implemented or not supported/enabled.
Constant Value: 12

#### public static final int
**UNKNOWN**

Unknown error or an error from a different error domain.
Constant Value: 2

#### public static final int
**UNSUPPORTED**

The feature is not supported on this device. Waiting or trying again won't resolve
it.
Constant Value: 18

## Public Methods

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

Gets the error code for the ML Kit operation that failed.