Interface FatalErrorHandler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FatalErrorHandler
A callback for any fatal (unchecked) exceptions

Also contains various default handlers

  • Method Details

    • handle

      void handle(@NotNull @NotNull Throwable e, @Nullable @Nullable Object context)
      Called when an unchecked exception is caught during execution of some task
      Parameters:
      e - the caught exception
      context - the context in which exception was caught in, possibly null
    • handle

      default void handle(@NotNull @NotNull Throwable e)
      Called when an unchecked exception is caught during execution of some task
      Parameters:
      e - the caught exception
      See Also:
    • andThen

      default FatalErrorHandler andThen(FatalErrorHandler nextHandler)
      Combines handlers by chaining the next handler after the current one
    • ignore

      static FatalErrorHandler ignore()
      A fatal error handler that simply ignores all received errors
    • halt

      static FatalErrorHandler halt()
      A fatal error handler that terminates JVM on any Throwable
    • haltOnError

      static FatalErrorHandler haltOnError()
      A fatal error handler that terminates JVM on any Error
    • haltOnVirtualMachineError

      static FatalErrorHandler haltOnVirtualMachineError()
      A fatal error handler that terminates JVM on any VirtualMachineError
    • haltOnOutOfMemoryError

      static FatalErrorHandler haltOnOutOfMemoryError()
      A fatal error handler that terminates JVM on any OutOfMemoryError
    • haltOn

      static FatalErrorHandler haltOn(Predicate<Throwable> predicate)
      A fatal error handler that terminates JVM on any error that matches a given predicate
      Parameters:
      predicate - a predicate that tests a received error
    • rethrow

      static FatalErrorHandler rethrow()
      A fatal error handler that rethrows any error it receives
    • rethrowOn

      static FatalErrorHandler rethrowOn(Predicate<Throwable> predicate)
      A fatal error handler that rethrows any error that matches a given predicate
      Parameters:
      predicate - a predicate that tests a received error
    • logging

      static FatalErrorHandler logging()
      A fatal error handler that logs all errors to an internal Logger
    • loggingTo

      static FatalErrorHandler loggingTo(org.slf4j.Logger logger)
      A fatal error handler that logs all errors to a given Logger
      Parameters:
      logger - a logger to log all the received errors
    • loggingToSystemOut

      static FatalErrorHandler loggingToSystemOut()
      A fatal error handler that logs all errors to a standard output stream
      See Also:
    • loggingToSystemErr

      static FatalErrorHandler loggingToSystemErr()
      A fatal error handler that logs all errors to a standard error output stream
      See Also:
    • loggingTo

      static FatalErrorHandler loggingTo(PrintStream stream)
      A fatal error handler that logs all errors to a given PrintStream
      Parameters:
      stream - a print stream to log all the received errors