Interface ErrorHandler

All Known Implementing Classes:
CrashOnError, ErrorPrinter, LoggerDisabler
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

An error handler is used by the Logged framework to catch and process any errors that occur during the logging process. Different handlers can be used in different operating modes, such as crashing in simulation to identify errors before they make it to a robot, or automatically disabling loggers if they encounter too many errors on the field to let the robot keep running while playing a match.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates an error handler that will immediately re-throw an exception and cause robot code to exit.
    disabling(int maximumPermissibleErrors)
    Creates an error handler that will automatically disable a logger if it encounters too many errors.
    void
    handle(Throwable exception, ClassSpecificLogger<?> logger)
    Handles an exception that arose while logging.
    Creates an error handler that will print error messages to the console output, but otherwise allow logging to continue in the future.
  • Method Details

    • handle

      void handle(Throwable exception, ClassSpecificLogger<?> logger)
      Handles an exception that arose while logging.
      Parameters:
      exception - the exception that occurred
      logger - the logger that was being processed that caused the error to occur
    • crashOnError

      Creates an error handler that will immediately re-throw an exception and cause robot code to exit. This is particularly useful when running in simulation or JUnit tests to identify errors quickly and safely.
      Returns:
      the error handler
    • printErrorMessages

      Creates an error handler that will print error messages to the console output, but otherwise allow logging to continue in the future. This can be helpful when errors occur only rarely and you don't want your robot program to crash or disable future logging.
      Returns:
      the error handler
    • disabling

      static LoggerDisabler disabling(int maximumPermissibleErrors)
      Creates an error handler that will automatically disable a logger if it encounters too many errors. Only the error-prone logger(s) will be disabled; loggers that have not encountered any errors, or encountered fewer than the limit, will continue to be used. Disabled loggers can be reset by calling LoggerDisabler.reset() on the handler.
      Parameters:
      maximumPermissibleErrors - the maximum number of errors that a logger is permitted to encounter before being disabled.
      Returns:
      the error handler