Record Class ErrorEvent

java.lang.Object
java.lang.Record
com.tnsai.events.ErrorEvent
Record Components:
eventId - unique identifier for this event
timestamp - when the event occurred
runId - the run identifier where the error occurred
code - error code for programmatic handling
message - human-readable error message
details - 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 Details

  • 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 a ErrorEvent record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      runId - the value for the runId record component
      code - the value for the code record component
      message - the value for the message record component
      details - the value for the details record component
      recoverable - the value for the recoverable record component
  • Method Details

    • of

      public static ErrorEvent of(String runId, String code, String message)
      Creates an error event.
      Parameters:
      runId - the run identifier
      code - the error code
      message - the error message
      Returns:
      new ErrorEvent
    • recoverable

      public static ErrorEvent recoverable(String runId, String code, String message)
      Creates a recoverable error event.
      Parameters:
      runId - the run identifier
      code - the error code
      message - 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 identifier
      code - the error code
      message - the error message
      details - additional details
      Returns:
      new ErrorEvent
    • fromException

      public static ErrorEvent fromException(String runId, Exception exception)
      Creates an error event from an exception.
      Parameters:
      runId - the run identifier
      exception - the exception that occurred
      Returns:
      new ErrorEvent
    • toolError

      public static ErrorEvent toolError(String runId, String toolName, String message)
      Creates a tool execution error event.
      Parameters:
      runId - the run identifier
      toolName - the tool that failed
      message - the error message
      Returns:
      new ErrorEvent
    • llmError

      public static ErrorEvent llmError(String runId, String message)
      Creates an LLM error event.
      Parameters:
      runId - the run identifier
      message - the error message
      Returns:
      new ErrorEvent
    • timeout

      public static ErrorEvent timeout(String runId, long timeoutMs)
      Creates a timeout error event.
      Parameters:
      runId - the run identifier
      timeoutMs - the timeout that was exceeded
      Returns:
      new ErrorEvent
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Specified by:
      eventId in interface TnsAIEvent
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface TnsAIEvent
      Returns:
      the value of the timestamp record component
    • runId

      public String runId()
      Returns the value of the runId record component.
      Returns:
      the value of the runId record component
    • code

      public String code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • details

      public Map<String,Object> details()
      Returns the value of the details record component.
      Returns:
      the value of the details record component
    • recoverable

      public boolean recoverable()
      Returns the value of the recoverable record component.
      Returns:
      the value of the recoverable record component