Class TnsAIException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ActionExecutionException,AgentValidationException,ApprovalRequiredException,CommunicationViolationException,GroupPolicyViolationException,IdempotencyException,InvariantViolationException,KnowledgeBaseException,LifecycleManager.LifecycleException,LifecycleManager.LifecycleTimeoutException,LLMException,MessageCallbackDispatcher.CallbackInvocationException,NetworkException,OutputSerializationException,ParseException,PromptException,RateLimitException,RoleAssignmentException,RoleInitializationException,SecurityException,StateException,TaskCompleteException,TimeoutException,ToolException,ValidationException
EventContext.
Every instance auto-captures the AgentContext.currentOptional()
thread-local at construction (issue #90). When operators see the
exception in a log they get the agent / role / session / tenant scope
inline — no MDC / log archaeology required.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTnsAIException(String message) TnsAIException(String message, boolean retryable) TnsAIException(String message, Throwable cause) TnsAIException(String message, Throwable cause, boolean retryable) -
Method Summary
Modifier and TypeMethodDescriptionFrameworkEventContextcaptured at construction time, if any.Gets the error code for this exception type.intGets maximum recommended retry attempts.Returns the message with the capturedEventContextappended in a compact, operator-readable form:longGets suggested retry delay in milliseconds.Wall-clock instant the exception was constructed.booleanChecks if this error is retryable.static TnsAIExceptionWrap an arbitrary throwable in aTnsAIExceptionso it carries a framework error code, retryable flag, and (via subclassing) flows uniformly throughErrorEmitter.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
TnsAIException
-
TnsAIException
-
TnsAIException
-
TnsAIException
-
-
Method Details
-
isRetryable
public boolean isRetryable()Checks if this error is retryable. Retryable errors are typically transient (network issues, rate limits, server errors).- Returns:
- true if the operation can be retried
-
getErrorCode
Gets the error code for this exception type. Format: TNSAI-XXX where XXX is derived from class name. -
getSuggestedRetryDelayMs
public long getSuggestedRetryDelayMs()Gets suggested retry delay in milliseconds. Override in subclasses for specific retry strategies. -
getMaxRetryAttempts
public int getMaxRetryAttempts()Gets maximum recommended retry attempts. -
getThrownAt
Wall-clock instant the exception was constructed. Useful for downstreamErrorReport.timestampfidelity (the report can be built later than the throw, e.g. inside a higher-up catch block).- Since:
- 0.5.0 (issue #90)
-
getContext
FrameworkEventContextcaptured at construction time, if any. Empty when the exception was constructed outside anAgentContext.enter(EventContext)scope (test harness, one-off main, third-party-thread). Once set, the context is frozen — later changes toAgentContext.current()do not reach back.- Since:
- 0.5.0 (issue #90)
-
getMessage
Returns the message with the capturedEventContextappended in a compact, operator-readable form:"<original message> [agent=A1, role=R, session=S, tenant=T]"Only the populated low-cardinality fields are included; missing ones are skipped so the suffix stays compact. When no context was captured, the original message is returned unchanged so existing log scrapers see the same prefix.
- Overrides:
getMessagein classThrowable- Since:
- 0.5.0 (issue #90)
-
wrap
Wrap an arbitrary throwable in aTnsAIExceptionso it carries a framework error code, retryable flag, and (via subclassing) flows uniformly throughErrorEmitter. Iftis already aTnsAIExceptionit is returned unchanged.Best-effort retryable classification: known-transient causes (
IOException,SocketTimeoutException,TimeoutException) are marked retryable; others default to non-retryable.Used at framework boundaries that catch third-party throwables and need a uniform internal type. Consumers should generally throw the original exception or a domain-specific
TnsAIExceptionsubclass — this wrapper is for defensive infrastructure code.- Since:
- 0.5.0 (issue #86)
-