Package org.apache.sling.api.servlets

# Interface ErrorHandler

@Deprecated @ConsumerType public interface ErrorHandler
Deprecated.
Use `JakartaErrorHandler` instead.
The `ErrorHandler` defines the interface of the service used by the Sling to handle calls to `HttpServletResponse.sendError` and to handle uncaught `Throwable`s.

## Method Summary

Modifier and Type
Method
Description
`void`
`handleError(int status, String message, SlingHttpServletRequest request, SlingHttpServletResponse response)`
Deprecated.
Called to render a response for a HTTP status code.
`void`
`handleError(Throwable throwable, SlingHttpServletRequest request, SlingHttpServletResponse response)`
Deprecated.
Called to render a response for an uncaught `Throwable`.

## Method Details

### handleError

void handleError(int status, String message, SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException
Deprecated.
Called to render a response for a HTTP status code. This method should set the response status and print the status code and optional message.

If the response has already been committed, an error message should be logged but no further processing should take place.

Parameters:
  `status` - The HTTP status code to set
  `message` - An optional message to write to the response. This message may be `null`.
  `request` - The request object providing more information on the request.
  `response` - The response object used to send the status and message.
Throws:
  `IOException` - May be thrown if an error occurrs sending the response.

### handleError

void handleError(Throwable throwable, SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException
Deprecated.
Called to render a response for an uncaught `Throwable`.

If the response has already been committed, an error message should be logged but no further processing should take place.

Parameters:
  `throwable` - The `Throwable` causing this method to be called.
  `request` - The request object providing more information on the request.
  `response` - The response object used to send the status and message.
Throws:
  `IOException` - May be thrown if an error occurrs sending the response.