Class ExceptionTracker

java.lang.Object
util.ExceptionTracker

public class ExceptionTracker extends Object
ExceptionTracker tracks and manages exceptions thrown, not thrown, and not checked during validation or testing. It provides methods to add, merge, and display categorized exceptions with colored output.
  • Constructor Details

    • ExceptionTracker

      public ExceptionTracker(String name)
      Constructs an ExceptionTracker for the given name.
      Parameters:
      name - the name associated with this tracker
  • Method Details

    • empty

      public static ExceptionTracker empty(String name)
      Creates an empty ExceptionTracker for the given name.
      Parameters:
      name - the name associated with this tracker
      Returns:
      a new ExceptionTracker instance
    • addThrownException

      public void addThrownException(Exception e)
      Adds an exception to the list of thrown exceptions.
      Parameters:
      e - the exception that was thrown
    • addNotThrownException

      public void addNotThrownException(Exception e)
      Adds an exception to the list of not thrown exceptions.
      Parameters:
      e - the exception that was expected but not thrown
    • addNotCheckedException

      public void addNotCheckedException(Exception e)
      Adds an exception to the list of not checked exceptions.
      Parameters:
      e - the exception that was not checked
    • getThrownExceptions

      public Map<String,List<CheckerException>> getThrownExceptions()
      Returns the map of thrown exceptions categorized by name.
      Returns:
      the map of thrown exceptions
    • getNotThrownExceptions

      public Map<String,List<CheckerException>> getNotThrownExceptions()
      Returns the map of not thrown exceptions categorized by name.
      Returns:
      the map of not thrown exceptions
    • merge

      public void merge(ExceptionTracker exceptionTracker)
      Merges another ExceptionTracker's exceptions into this one, combining all categories by name.
      Parameters:
      exceptionTracker - the ExceptionTracker to merge from
    • hasErrors

      public boolean hasErrors()
      Checks if there are any thrown exceptions.
      Returns:
      true if there are thrown exceptions, false otherwise
    • hasNotErrors

      public boolean hasNotErrors()
      Checks if there are no thrown exceptions.
      Returns:
      true if there are no thrown exceptions, false otherwise
    • showThrownException

      public void showThrownException()
      Displays all thrown exceptions in red color.
    • showNotThrownException

      public void showNotThrownException()
      Displays all not thrown exceptions in green color.
    • showNotCheckedThrownException

      public void showNotCheckedThrownException()
      Displays all not checked exceptions in yellow color.
    • show

      public void show()
      Displays all categories of exceptions: thrown, not thrown, and not checked.