Class ExtractionException

All Implemented Interfaces:
Serializable

public class ExtractionException extends RuntimeException
Thrown when EasyAI cannot turn the source content into the requested type.

Analogy: like a NumberFormatException for AI extraction — the input could not be coerced into the shape you asked for. It is unchecked so it does not clutter call sites, but it carries a clear message and (where relevant) the model's raw output so you can see what went wrong.

Raised by ExtractionBuilder.from(String) (and its overloads) in two situations:

  • the model never produced parseable JSON matching the target type, even after the configured retries;
  • .validate() was enabled and the extracted object failed Jakarta Bean Validation.
See Also:
  • Constructor Details

    • ExtractionException

      public ExtractionException(String message)
      Creates an exception with a human-readable message.
      Parameters:
      message - what went wrong (and, where useful, the model's raw output)
    • ExtractionException

      public ExtractionException(String message, Throwable cause)
      Creates an exception wrapping an underlying cause (e.g. a JSON parse error).
      Parameters:
      message - what went wrong
      cause - the underlying exception