- All Superinterfaces:
BiFunction<ErrorHandler.Location,
Throwable, Boolean>
This interface allows to handle a socket error and provides a default way to do so
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The constants of this enumerated type describe the various locations where an error can occur in the socket -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ErrorHandler
defaultErrorHandler
(BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored) Default error handlerstatic ErrorHandler
defaultErrorHandler
(Consumer<Throwable> exceptionPrinter) Default error handlerstatic ErrorHandler
defaultErrorHandler
(Consumer<Throwable> exceptionPrinter, BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored, System.Logger.Level loggingLevel) Default error handlerstatic ErrorHandler
toFile()
Default error handler.static ErrorHandler
toFile
(BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored) Default error handler.static ErrorHandler
Default error handler.static ErrorHandler
toTerminal
(BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored) Default error handler.Methods inherited from interface java.util.function.BiFunction
andThen, apply
-
Field Details
-
LOGGER
System logger. A nice feature from Java 9.
-
-
Method Details
-
toTerminal
Default error handler. Prints the exception on the terminal.- Returns:
- a non-null error handler
-
toTerminal
static ErrorHandler toTerminal(BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored) Default error handler. Prints the exception on the terminal.- Parameters:
onRestore
- action to execute if the session is restored, can be nullonIgnored
- action to execute if the session is not restored, can be null- Returns:
- a non-null error handler
-
toFile
Default error handler. Saves the exception locally.- Returns:
- a non-null error handler
-
toFile
static ErrorHandler toFile(BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored) Default error handler. Saves the exception locally.- Parameters:
onRestore
- action to execute if the session is restored, can be nullonIgnored
- action to execute if the session is not restored, can be null- Returns:
- a non-null error handler
-
defaultErrorHandler
Default error handler- Parameters:
exceptionPrinter
- a consumer that handles the printing of the throwable, can be null- Returns:
- a non-null error handler
-
defaultErrorHandler
static ErrorHandler defaultErrorHandler(BiConsumer<ErrorHandler.Location, Throwable> onRestore, BiConsumer<ErrorHandler.Location, Throwable> onIgnored) Default error handler- Parameters:
onRestore
- action to execute if the session is restored, can be nullonIgnored
- 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 nullonRestore
- action to execute if the session is restored, can be nullonIgnored
- action to execute if the session is not restored, can be nullloggingLevel
- the level used to log messages about the error, can be null if no logging should be done- Returns:
- a non-null error handler
-