Package edu.wpi.grip.core.util
Class ExceptionWitness
- java.lang.Object
-
- edu.wpi.grip.core.util.ExceptionWitness
-
public class ExceptionWitness extends java.lang.ObjectWitnesses and reports exception. This class is not suitable to handleErrors.flagException(java.lang.Exception, java.lang.String)should be used to flag the witness that an error has has occurred. This will post anExceptionEventto theEventBus.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"); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceExceptionWitness.Factory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearException()Indicate that there isn't currently an exception.voidflagException(java.lang.Exception exception)Indicates to the witness that an exception has occurred.voidflagException(java.lang.Exception exception, java.lang.String message)Indicates to the witness that an exception has occurred.voidflagWarning(java.lang.String warningMessage)Allows a warning to be flagged without an exception.booleanisException()
-
-
-
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 anExceptionEventto theEventBus- 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 anExceptionClearedEvent. This method can be called every time that there isn't an exception as anExceptionClearedEventwill 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.
-
-