Record Class CauseInfo

java.lang.Object
java.lang.Record
com.tnsai.observability.errors.CauseInfo
Record Components:
errorClass - fully-qualified throwable class name
message - user-visible message — pass through Redactor before serialization
location - top stack frame in the form "Class.method(File.java:42)" (may be null if no stack frames)

public record CauseInfo(String errorClass, String message, String location) extends Record
Compact summary of a single throwable in a flattened cause chain.

Operators see the full chain in one structured view rather than walking getCause().getCause().getCause(). Each entry carries just enough to identify the origin: the throwable's fully-qualified class name, its (redaction-safe) message, and the top stack frame.

Since:
0.5.0 (issue #86)
  • Constructor Details

    • CauseInfo

      public CauseInfo(String errorClass, String message, String location)
      Creates an instance of a CauseInfo record class.
      Parameters:
      errorClass - the value for the errorClass record component
      message - the value for the message record component
      location - the value for the location record component
  • Method Details

    • of

      public static CauseInfo of(Throwable t)
      Build a CauseInfo from a throwable. The top stack frame (if any) is recorded as location.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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
    • message

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

      public String location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component