Interface ErrorHandler


public interface ErrorHandler
This interface allows to handle a socket error and provides a default way to do so
  • Method Details

    • handleError

      ErrorHandler.Result handleError(Whatsapp whatsapp, ErrorHandler.Location location, Throwable throwable)
      Handles an error that occurred inside the api
      Parameters:
      whatsapp - the caller api
      location - the location where the error occurred
      throwable - a stacktrace of the error, if available
      Returns:
      a newsletters determining what should be done
    • toTerminal

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

      static ErrorHandler toFile()
      Default error handler. Saves the exception locally. The file will be saved in $HOME/.cobalt/errors
      Returns:
      a non-null error handler
    • toFile

      static ErrorHandler toFile(Path directory)
      Default error handler. Saves the exception locally. The file will be saved in directory.
      Parameters:
      directory - the directory where the error should be saved
      Returns:
      a non-null error handler
    • defaultErrorHandler

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