org.apache.sling.engine.impl
Class DefaultErrorHandler

java.lang.Object
  extended by org.apache.sling.engine.impl.DefaultErrorHandler
All Implemented Interfaces:
ErrorHandler

public class DefaultErrorHandler
extends Object
implements ErrorHandler

The DefaultErrorHandler is used by the SlingRequestProcessorImpl as long as no ErrorHandler service is registered.


Constructor Summary
DefaultErrorHandler()
           
 
Method Summary
 void handleError(int status, String message, SlingHttpServletRequest request, SlingHttpServletResponse response)
          Backend implementation of the HttpServletResponse.sendError methods.
 void handleError(Throwable throwable, SlingHttpServletRequest request, SlingHttpServletResponse response)
          Backend implementation of handling uncaught throwables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultErrorHandler

public DefaultErrorHandler()
Method Detail

handleError

public void handleError(int status,
                        String message,
                        SlingHttpServletRequest request,
                        SlingHttpServletResponse response)
                 throws IOException
Backend implementation of the HttpServletResponse.sendError methods.

This implementation resets the response before sending back a standardized response which just conveys the status, the message (either provided or a message derived from the status code), and server information.

This method logs error and does not write back and response data if the response has already been committed.

Specified by:
handleError in interface ErrorHandler
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

public void handleError(Throwable throwable,
                        SlingHttpServletRequest request,
                        SlingHttpServletResponse response)
                 throws IOException
Backend implementation of handling uncaught throwables.

This implementation resets the response before sending back a standardized response which just conveys the status as 500/INTERNAL SERVER ERROR, the message from the throwable, the stacktrace, and server information.

This method logs error and does not write back and response data if the response has already been committed.

Specified by:
handleError in interface ErrorHandler
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.


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.