public interface ErrorHandler
This interface allows to handle a socket error and provides a default way to do so
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe constants of this enumerated type describe the various locations where an error can occur in the socketstatic enumThe constants of this enumerated type describe the various types of actions that can be performed by an error handler in newsletters to a throwable -
Method Summary
Modifier and TypeMethodDescriptionstatic ErrorHandlerdefaultErrorHandler(Consumer<Throwable> printer) Default error handlerhandleError(ClientType type, ErrorHandler.Location location, Throwable throwable) Handles an error that occurred inside the apistatic ErrorHandlertoFile()Default error handler.static ErrorHandlerDefault error handler.static ErrorHandlerDefault error handler.
-
Method Details
-
handleError
ErrorHandler.Result handleError(ClientType type, ErrorHandler.Location location, Throwable throwable) Handles an error that occurred inside the api- Parameters:
type- the type of client experiencing the errorlocation- the location where the error occurredthrowable- a stacktrace of the error, if available- Returns:
- a newsletters determining what should be done
-
toTerminal
Default error handler. Prints the exception on the terminal.- Returns:
- a non-null error handler
-
toFile
Default error handler. Saves the exception locally. The file will be saved in $HOME/.cobalt/errors- Returns:
- a non-null error handler
-
toFile
Default error handler. Saves the exception locally. The file will be saved indirectory.- Parameters:
directory- the directory where the error should be saved- Returns:
- a non-null error handler
-
defaultErrorHandler
Default error handler- Parameters:
printer- a consumer that handles the printing of the throwable, can be null- Returns:
- a non-null error handler
-