Class ExceptionWitness


  • public class ExceptionWitness
    extends java.lang.Object
    Witnesses and reports exception. This class is not suitable to handle Errors.

    flagException(java.lang.Exception, java.lang.String) should be used to flag the witness that an error has has occurred. This will post an ExceptionEvent to the EventBus.

    Example Usage:

     
     while(true){
         try {
              // Do something that may throw an exception
              witness.clearException();
         } catch (Exception e) {
            witness.flagException(e, "There was a problem in this while loop");
         }
     }
     
     
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearException()
      Indicate that there isn't currently an exception.
      void flagException​(java.lang.Exception exception)
      Indicates to the witness that an exception has occurred.
      void flagException​(java.lang.Exception exception, java.lang.String message)
      Indicates to the witness that an exception has occurred.
      void flagWarning​(java.lang.String warningMessage)
      Allows a warning to be flagged without an exception.
      boolean isException()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • flagException

        public final void flagException​(java.lang.Exception exception,
                                        @Nullable
                                        java.lang.String message)
        Indicates to the witness that an exception has occurred. This will also post an ExceptionEvent to the EventBus
        Parameters:
        exception - The exception that this is reporting. If the Exception is an InterruptedException then this will not post an exception, instead, it will set the threads interrupted state and return.
        message - Any additional details that should be associated with this message.
      • flagException

        public final void flagException​(java.lang.Exception exception)
        Indicates to the witness that an exception has occurred.
        See Also:
        flagException(Exception, String)
      • flagWarning

        public final void flagWarning​(java.lang.String warningMessage)
        Allows a warning to be flagged without an exception. This should never be done when there is an exception involved.
        Parameters:
        warningMessage - The message to flag.
      • clearException

        public final void clearException()
        Indicate that there isn't currently an exception. Clears the exception state and posts an ExceptionClearedEvent. This method can be called every time that there isn't an exception as an ExceptionClearedEvent will only be posted when there was previously an exception flagged.
      • isException

        public final boolean isException()
        Returns:
        true if an exception has been flagged and not cleared.