Interface ErrorHandler

All Superinterfaces:
BiFunction<ErrorHandler.Location,Throwable,Boolean>

public interface ErrorHandler extends BiFunction<ErrorHandler.Location,Throwable,Boolean>
This interface allows to handle a socket error and provides a default way to do so
  • Field Details

    • LOGGER

      static final System.Logger LOGGER
      System logger. A nice feature from Java 9.
  • Method Details

    • toTerminal

      static ErrorHandler toTerminal()
      Default error handler. Prints the exception on the terminal.
      Returns:
      a non-null error handler
    • toTerminal

      Default error handler. Prints the exception on the terminal.
      Parameters:
      onRestore - action to execute if the session is restored, can be null
      onIgnored - action to execute if the session is not restored, can be null
      Returns:
      a non-null error handler
    • toFile

      static ErrorHandler toFile()
      Default error handler. Saves the exception locally.
      Returns:
      a non-null error handler
    • toFile

      Default error handler. Saves the exception locally.
      Parameters:
      onRestore - action to execute if the session is restored, can be null
      onIgnored - action to execute if the session is not restored, can be null
      Returns:
      a non-null error handler
    • defaultErrorHandler

      static ErrorHandler defaultErrorHandler(Consumer<Throwable> exceptionPrinter)
      Default error handler
      Parameters:
      exceptionPrinter - a consumer that handles the printing of the throwable, can be null
      Returns:
      a non-null error handler
    • defaultErrorHandler

      Default error handler
      Parameters:
      onRestore - action to execute if the session is restored, can be null
      onIgnored - action to execute if the session is not restored, can be null
      Returns:
      a non-null error handler
    • defaultErrorHandler

      static ErrorHandler defaultErrorHandler(Consumer<Throwable> exceptionPrinter, BiConsumer<ErrorHandler.Location,Throwable> onRestore, BiConsumer<ErrorHandler.Location,Throwable> onIgnored, System.Logger.Level loggingLevel)
      Default error handler
      Parameters:
      exceptionPrinter - a consumer that handles the printing of the throwable, can be null
      onRestore - action to execute if the session is restored, can be null
      onIgnored - action to execute if the session is not restored, can be null
      loggingLevel - the level used to log messages about the error, can be null if no logging should be done
      Returns:
      a non-null error handler