Module io.jooby
Package io.jooby

Interface ErrorHandler

All Known Implementing Classes:
DefaultErrorHandler

public interface ErrorHandler
Catch and encode application errors.
Since:
2.0.0
Author:
edgar
  • Method Details

    • apply

      @NonNull void apply(@NonNull Context ctx, @NonNull Throwable cause, @NonNull StatusCode code)
      Produces an error response using the given exception and status code.
      Parameters:
      ctx - Web context.
      cause - Application error.
      code - Status code.
    • then

      @NonNull default ErrorHandler then(@NonNull ErrorHandler next)
      Chain this error handler with next and produces a new error handler.
      Parameters:
      next - Next error handler.
      Returns:
      A new error handler.
    • errorMessage

      @NonNull static String errorMessage(@NonNull Context ctx, @NonNull StatusCode statusCode)
      Build a line error message that describe the current web context and the status code.
      GET /path Status-Code Status-Reason
      Parameters:
      ctx - Web context.
      statusCode - Status code.
      Returns:
      Single line message.
    • create

      @NonNull static DefaultErrorHandler create()
      Creates a default error handler.
      Returns:
      Default error handler.