Package com.tnsai.events
Record Class ErrorEvent
java.lang.Object
java.lang.Record
com.tnsai.events.ErrorEvent
- Record Components:
eventId- unique identifier for this eventtimestamp- when the event occurredrunId- the run identifier where the error occurredcode- error code for programmatic handlingmessage- human-readable error messagedetails- additional error details (stack trace, context)recoverable- true if execution can potentially continue
- All Implemented Interfaces:
TnsAIEvent
public record ErrorEvent(String eventId, Instant timestamp, String runId, String code, String message, Map<String,Object> details, boolean recoverable)
extends Record
implements TnsAIEvent
Event representing an error during agent execution.
ErrorEvent is emitted when something goes wrong during execution. It contains details about the error for debugging and user notification.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.details()Returns the value of thedetailsrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.static ErrorEventfromException(String runId, Exception exception) Creates an error event from an exception.final inthashCode()Returns a hash code value for this object.static ErrorEventCreates an LLM error event.message()Returns the value of themessagerecord component.static ErrorEventCreates an error event.booleanReturns the value of therecoverablerecord component.static ErrorEventrecoverable(String runId, String code, String message) Creates a recoverable error event.runId()Returns the value of therunIdrecord component.static ErrorEventCreates a timeout error event.Returns the value of thetimestamprecord component.static ErrorEventCreates a tool execution error event.final StringtoString()Returns a string representation of this record class.static ErrorEventCreates an error event with details.Methods inherited from interface com.tnsai.events.TnsAIEvent
eventType
-
Field Details
-
CODE_TOOL_EXECUTION_FAILED
Common error codes.- See Also:
-
CODE_LLM_ERROR
- See Also:
-
CODE_TIMEOUT
- See Also:
-
CODE_VALIDATION_ERROR
- See Also:
-
CODE_AUTHENTICATION_ERROR
- See Also:
-
CODE_RATE_LIMIT
- See Also:
-
CODE_INTERNAL_ERROR
- See Also:
-
-
Constructor Details
-
ErrorEvent
public ErrorEvent(String eventId, Instant timestamp, String runId, String code, String message, Map<String, Object> details, boolean recoverable) Creates an instance of aErrorEventrecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentrunId- the value for therunIdrecord componentcode- the value for thecoderecord componentmessage- the value for themessagerecord componentdetails- the value for thedetailsrecord componentrecoverable- the value for therecoverablerecord component
-
-
Method Details
-
of
Creates an error event.- Parameters:
runId- the run identifiercode- the error codemessage- the error message- Returns:
- new ErrorEvent
-
recoverable
Creates a recoverable error event.- Parameters:
runId- the run identifiercode- the error codemessage- the error message- Returns:
- new ErrorEvent
-
withDetails
public static ErrorEvent withDetails(String runId, String code, String message, Map<String, Object> details) Creates an error event with details.- Parameters:
runId- the run identifiercode- the error codemessage- the error messagedetails- additional details- Returns:
- new ErrorEvent
-
fromException
Creates an error event from an exception.- Parameters:
runId- the run identifierexception- the exception that occurred- Returns:
- new ErrorEvent
-
toolError
Creates a tool execution error event.- Parameters:
runId- the run identifiertoolName- the tool that failedmessage- the error message- Returns:
- new ErrorEvent
-
llmError
Creates an LLM error event.- Parameters:
runId- the run identifiermessage- the error message- Returns:
- new ErrorEvent
-
timeout
Creates a timeout error event.- Parameters:
runId- the run identifiertimeoutMs- the timeout that was exceeded- Returns:
- new ErrorEvent
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
eventId
Returns the value of theeventIdrecord component.- Specified by:
eventIdin interfaceTnsAIEvent- Returns:
- the value of the
eventIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceTnsAIEvent- Returns:
- the value of the
timestamprecord component
-
runId
Returns the value of therunIdrecord component.- Returns:
- the value of the
runIdrecord component
-
code
Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
details
Returns the value of thedetailsrecord component.- Returns:
- the value of the
detailsrecord component
-
recoverable
public boolean recoverable()Returns the value of therecoverablerecord component.- Returns:
- the value of the
recoverablerecord component
-