Class ParseException

All Implemented Interfaces:
Serializable

public class ParseException extends TnsAIException
Exception thrown when LLM output cannot be parsed into the expected type.

Contains the raw output and error details to help diagnose parsing issues and potentially retry with error correction.

See Also:
  • Constructor Details

    • ParseException

      public ParseException(String message)
      Creates a new parse exception.
      Parameters:
      message - the error message
      rawOutput - the raw output that failed to parse
    • ParseException

      public ParseException(String message, String rawOutput)
    • ParseException

      public ParseException(String message, String rawOutput, String expectedFormat)
      Creates a new parse exception with expected format.
      Parameters:
      message - the error message
      rawOutput - the raw output that failed to parse
      expectedFormat - description of expected format
    • ParseException

      public ParseException(String message, String rawOutput, Throwable cause)
      Creates a new parse exception with a cause.
      Parameters:
      message - the error message
      rawOutput - the raw output that failed to parse
      cause - the underlying cause
  • Method Details

    • getRawOutput

      public String getRawOutput()
      Gets the raw output that failed to parse.
      Returns:
      the raw output
    • getExpectedFormat

      public String getExpectedFormat()
      Gets the expected format description if available.
      Returns:
      expected format or null
    • getTruncatedRawOutput

      public String getTruncatedRawOutput(int maxLength)
      Creates a truncated version of the raw output for logging.
      Parameters:
      maxLength - maximum length
      Returns:
      truncated raw output
    • toString

      public String toString()
      Overrides:
      toString in class Throwable