Class ExceptionTracker
java.lang.Object
util.ExceptionTracker
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 Summary
ConstructorsConstructorDescriptionExceptionTracker
(String name) Constructs an ExceptionTracker for the given name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an exception to the list of not checked exceptions.void
Adds an exception to the list of not thrown exceptions.void
Adds an exception to the list of thrown exceptions.static ExceptionTracker
Creates an empty ExceptionTracker for the given name.Returns the map of not thrown exceptions categorized by name.Returns the map of thrown exceptions categorized by name.boolean
Checks if there are any thrown exceptions.boolean
Checks if there are no thrown exceptions.void
merge
(ExceptionTracker exceptionTracker) Merges another ExceptionTracker's exceptions into this one, combining all categories by name.void
show()
Displays all categories of exceptions: thrown, not thrown, and not checked.void
Displays all not checked exceptions in yellow color.void
Displays all not thrown exceptions in green color.void
Displays all thrown exceptions in red color.
-
Constructor Details
-
ExceptionTracker
Constructs an ExceptionTracker for the given name.- Parameters:
name
- the name associated with this tracker
-
-
Method Details
-
empty
Creates an empty ExceptionTracker for the given name.- Parameters:
name
- the name associated with this tracker- Returns:
- a new ExceptionTracker instance
-
addThrownException
Adds an exception to the list of thrown exceptions.- Parameters:
e
- the exception that was thrown
-
addNotThrownException
Adds an exception to the list of not thrown exceptions.- Parameters:
e
- the exception that was expected but not thrown
-
addNotCheckedException
Adds an exception to the list of not checked exceptions.- Parameters:
e
- the exception that was not checked
-
getThrownExceptions
Returns the map of thrown exceptions categorized by name.- Returns:
- the map of thrown exceptions
-
getNotThrownExceptions
Returns the map of not thrown exceptions categorized by name.- Returns:
- the map of not thrown exceptions
-
merge
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.
-