# Class VisionException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.codename1.ai.vision.VisionException

public class VisionException extends RuntimeException

Failure reported by an on-device vision backend.

The code separates "this device will never do this" from "this attempt failed", which usually calls for different UI:

    recognizer.process(image)
        .ready(result -> textArea.setText(result.getText()))
        .except(error -> {
            if (error instanceof VisionException
                    && ((VisionException) error).getCode()
                            == VisionException.UNSUPPORTED) {
                // Permanent: hide the feature rather than offering a retry.
                scanButton.setVisible(false);
                return;
            }
            ToastBar.showErrorMessage("Could not read that image");
            Log.e(error);
        });

Prefer `isSupported()` on the analyzer to reaching this state at all; `UNSUPPORTED` is the answer to a question that could have been asked before the screen was shown.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `BACKEND_ERROR`
  `static final int`
  `CANCELLED`
  `static final int`
  `INVALID_IMAGE`
  `static final int`
  `MODEL_UNAVAILABLE`
  `static final int`
  `UNSUPPORTED`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VisionException(int code, String message)`
  Creates a classified vision failure.
  `VisionException(int code, String message, Throwable cause)`
  Creates a classified vision failure with its native or port cause.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getCode()`

  ### Methods inherited from class Throwable

  `addSuppressed, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### UNSUPPORTED

    public static final int UNSUPPORTED
    See Also:
      - Constant Field Values

  - ### INVALID_IMAGE

    public static final int INVALID_IMAGE
    See Also:
      - Constant Field Values

  - ### MODEL_UNAVAILABLE

    public static final int MODEL_UNAVAILABLE
    See Also:
      - Constant Field Values

  - ### CANCELLED

    public static final int CANCELLED
    See Also:
      - Constant Field Values

  - ### BACKEND_ERROR

    public static final int BACKEND_ERROR
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### VisionException

    public VisionException(int code, String message)
    Creates a classified vision failure.
    Parameters:
      `code` - portable failure code defined by this class
      `message` - user-readable failure description

  - ### VisionException

    public VisionException(int code, String message, Throwable cause)
    Creates a classified vision failure with its native or port cause.
    Parameters:
      `code` - portable failure code defined by this class
      `message` - user-readable failure description
      `cause` - originating detector or image-conversion error

- ## Method Details

  - ### getCode

    public int getCode()
    Returns:
      one of this class's portable failure-code constants