Package com.tnsai.exceptions
Class LLMException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.tnsai.exceptions.TnsAIException
com.tnsai.exceptions.LLMException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LLMCapabilityException
Exception for LLM-related errors (model errors, invalid responses, etc.).
Retryability depends on the specific error type.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionLLMException(String message) LLMException(String message, String model, LLMException.ErrorType errorType) LLMException(String message, String model, LLMException.ErrorType errorType, ProviderDetails providerDetails) LLMException(String message, Throwable cause) LLMException(String message, Throwable cause, String model, LLMException.ErrorType errorType) LLMException(String message, Throwable cause, String model, LLMException.ErrorType errorType, ProviderDetails providerDetails) -
Method Summary
Modifier and TypeMethodDescriptionstatic LLMExceptionauthenticationFailed(String model, String reason) Factory method for authentication errors.static LLMExceptioncontentFiltered(String model, String reason) Factory method for content filter errors.static LLMExceptioncontextTooLong(String model, int maxTokens, int requestedTokens) Factory method for context length errors.getModel()Native error envelope from the upstream provider, when surfaced.longGets suggested retry delay in milliseconds.static LLMExceptionmalformedToolCall(String model, String toolName, String details) Factory method for malformed tool call errors without a cause.static LLMExceptionmalformedToolCall(String model, String toolName, String details, Throwable cause) Factory method for malformed tool call errors.static LLMExceptionmodelNotFound(String model) Factory method for model not found errors.static LLMExceptionmodelOverloaded(String model) Factory method for model overloaded errors.static LLMExceptionserverError(String model, Throwable cause) Factory method for server errors.Methods inherited from class com.tnsai.exceptions.TnsAIException
getContext, getErrorCode, getMaxRetryAttempts, getMessage, getThrownAt, isRetryable, wrapMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
LLMException
-
LLMException
-
LLMException
-
LLMException
public LLMException(String message, Throwable cause, String model, LLMException.ErrorType errorType) -
LLMException
public LLMException(String message, String model, LLMException.ErrorType errorType, ProviderDetails providerDetails) - Since:
- 0.5.0 (issue #87)
-
LLMException
public LLMException(String message, Throwable cause, String model, LLMException.ErrorType errorType, ProviderDetails providerDetails) - Since:
- 0.5.0 (issue #87)
-
-
Method Details
-
getModel
-
getErrorType
-
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:TnsAIExceptionGets suggested retry delay in milliseconds. Override in subclasses for specific retry strategies.- Overrides:
getSuggestedRetryDelayMsin classTnsAIException
-
modelNotFound
Factory method for model not found errors. -
authenticationFailed
Factory method for authentication errors. -
contentFiltered
Factory method for content filter errors. -
contextTooLong
Factory method for context length errors. -
modelOverloaded
Factory method for model overloaded errors. -
serverError
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 calltoolName- the tool name (may be null if unparseable)details- description of what was malformedcause- the underlying parsing exception
-
malformedToolCall
Factory method for malformed tool call errors without a cause.
-