Class LLMException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LLMCapabilityException

public class LLMException extends TnsAIException
Exception for LLM-related errors (model errors, invalid responses, etc.). Retryability depends on the specific error type.
See Also:
  • Constructor Details

  • Method Details

    • getModel

      public String getModel()
    • getErrorType

      public LLMException.ErrorType getErrorType()
    • getProviderDetails

      public Optional<ProviderDetails> getProviderDetails()
      Native error envelope from the upstream provider, when surfaced. Empty when the failure is at the transport layer (DNS, connection reset, no parseable error body) or the throw site predates the provider-error-code transparency work in #87.
      Since:
      0.5.0 (issue #87)
    • getSuggestedRetryDelayMs

      public long getSuggestedRetryDelayMs()
      Description copied from class: TnsAIException
      Gets suggested retry delay in milliseconds. Override in subclasses for specific retry strategies.
      Overrides:
      getSuggestedRetryDelayMs in class TnsAIException
    • modelNotFound

      public static LLMException modelNotFound(String model)
      Factory method for model not found errors.
    • authenticationFailed

      public static LLMException authenticationFailed(String model, String reason)
      Factory method for authentication errors.
    • contentFiltered

      public static LLMException contentFiltered(String model, String reason)
      Factory method for content filter errors.
    • contextTooLong

      public static LLMException contextTooLong(String model, int maxTokens, int requestedTokens)
      Factory method for context length errors.
    • modelOverloaded

      public static LLMException modelOverloaded(String model)
      Factory method for model overloaded errors.
    • serverError

      public static LLMException serverError(String model, Throwable cause)
      Factory method for server errors.
    • malformedToolCall

      public static LLMException malformedToolCall(String model, String toolName, String details, Throwable cause)
      Factory method for malformed tool call errors.
      Parameters:
      model - the model that produced the malformed tool call
      toolName - the tool name (may be null if unparseable)
      details - description of what was malformed
      cause - the underlying parsing exception
    • malformedToolCall

      public static LLMException malformedToolCall(String model, String toolName, String details)
      Factory method for malformed tool call errors without a cause.