Record Class ErrorInfo

java.lang.Object
java.lang.Record
com.tnsai.llm.observability.ErrorInfo

public record ErrorInfo(String errorClass, String errorMessage, int httpStatus, Optional<String> providerErrorCode, boolean retryable) extends Record
Failure detail for a non-successful LLM call (issue #79).

Captured by the LLM call wrapper into LLMCallLog.error(); empty when the call succeeded. Retains the throwable's class name + message rather than the throwable itself so the log record stays serializable across stores (the consumer's classpath may not have the original exception class loaded).

httpStatus is 0 when the failure is at the transport layer (DNS, connection reset) — i.e. no HTTP response was received.

Since:
0.5.0 (issue #79)
  • Constructor Summary

    Constructors
    Constructor
    Description
    ErrorInfo(String errorClass, String errorMessage, int httpStatus, Optional<String> providerErrorCode, boolean retryable)
    Creates an instance of a ErrorInfo record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the errorClass record component.
    Returns the value of the errorMessage record component.
    static ErrorInfo
    from(Throwable t, int httpStatus, String providerErrorCode, boolean retryable)
    Build an ErrorInfo from a throwable, defaulting unknown fields.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the httpStatus record component.
    Returns the value of the providerErrorCode record component.
    boolean
    Returns the value of the retryable record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ErrorInfo

      public ErrorInfo(String errorClass, String errorMessage, int httpStatus, Optional<String> providerErrorCode, boolean retryable)
      Creates an instance of a ErrorInfo record class.
      Parameters:
      errorClass - the value for the errorClass record component
      errorMessage - the value for the errorMessage record component
      httpStatus - the value for the httpStatus record component
      providerErrorCode - the value for the providerErrorCode record component
      retryable - the value for the retryable record component
  • Method Details

    • from

      public static ErrorInfo from(Throwable t, int httpStatus, String providerErrorCode, boolean retryable)
      Build an ErrorInfo from a throwable, defaulting unknown fields. The caller fills in HTTP status / provider code if they have it; otherwise pass 0 / empty.
    • 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.
    • errorClass

      public String errorClass()
      Returns the value of the errorClass record component.
      Returns:
      the value of the errorClass record component
    • errorMessage

      public String errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • httpStatus

      public int httpStatus()
      Returns the value of the httpStatus record component.
      Returns:
      the value of the httpStatus record component
    • providerErrorCode

      public Optional<String> providerErrorCode()
      Returns the value of the providerErrorCode record component.
      Returns:
      the value of the providerErrorCode record component
    • retryable

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