Class TrackedError

java.lang.Object
io.github.projectunified.faststats.errortracker.TrackedError

public final class TrackedError extends Object
An error report with tracking metadata.

The error is snapshotted when this report is created, so modifications of the original Throwable afterwards do not change the report or its identity. Reports are deduplicated by their error snapshot only; the metadata added later (handled(boolean), attributes(Map)) is not part of the identity.

  • Constructor Details

    • TrackedError

      public TrackedError(Throwable error)
      Creates a new tracked error.
      Parameters:
      error - the error
  • Method Details

    • error

      Returns the snapshot of the tracked error.
      Returns:
      the error snapshot
    • handled

      public boolean handled()
      Returns whether the error was handled.
      Returns:
      whether the error was handled
    • handled

      public TrackedError handled(boolean handled)
      Sets whether the error was handled.
      Parameters:
      handled - whether the error was handled
      Returns:
      this tracked error
    • attributes

      public Map<String,Object> attributes()
      Returns a copy of the additional error attributes.
      Returns:
      a copy of the additional error attributes
    • attributes

      public TrackedError attributes(Map<String,Object> attributes)
      Sets the additional error attributes.
      Parameters:
      attributes - the additional error attributes
      Returns:
      this tracked error
    • attributes

      public TrackedError attributes(Consumer<Map<String,Object>> consumer)
      Modifies the additional error attributes using a consumer.
      Parameters:
      consumer - the consumer to modify attributes
      Returns:
      this tracked error
    • attributes

      public TrackedError attributes(Supplier<Map<String,Object>> supplier)
      Sets the additional error attributes using a supplier.
      Parameters:
      supplier - the supplier of attributes
      Returns:
      this tracked error
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object