smbdav
Interface ErrorHandler

All Known Implementing Classes:
DefaultAuthErrorHandler, DefaultIOErrorHandler

public interface ErrorHandler

A class can implement the ErrorHandler interface when it wishes to handle errors thrown by the method handler for the current request. The Davenport servlet installs error handlers in a chain. The first installed handler is invoked and given the chance to handle the error/exception; if it rethrows the exception, the next installed handler is invoked. If unhandled, the error is thrown from the servlet and handled by the container. To install a handler,

As an example, if you have a class com.foo.MyErrorHandler implementing smbdav.ErrorHandler, you would add the following to the Davenport deployment descriptor:

 <init-param>
     <param-name>errorHandlers</param-name>
     <param-value>com.foo.MyErrorHandler</param-value>
 </init-param>
 

If no handlers are specified, Davenport installs instances of smbdav.DefaultAuthErrorHandler and smbdav.DefaultIOErrorHandler. If installing your own handler, it may be desirable to include these as "fallback" handlers:

 <init-param>
     <param-name>errorHandlers</param-name>
     <param-value>com.foo.MyErrorHandler
                  smbdav.DefaultAuthErrorHandler
                  smbdav.DefaultIOErrorHandler</param-value>
 </init-param>
 

Author:
Eric Glass

Method Summary
 void destroy()
          Called by the Davenport servlet to indicate that the handler is being taken out of service.
 void handle(java.lang.Throwable throwable, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Called by the Davenport servlet to allow the error handler to process an error.
 void init(javax.servlet.ServletConfig config)
          Called by the Davenport servlet to indicate that the handler is being placed into service.
 

Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Called by the Davenport servlet to indicate that the handler is being placed into service. Semantics are identical to the Servlet init method; the method is called exactly once after instantiation.

Parameters:
config - a ServletConfig object containing the Davenport servlet's configuration and initialization parameters.
Throws:
javax.servlet.ServletException - If an error occurs during initialization.

destroy

public void destroy()
Called by the Davenport servlet to indicate that the handler is being taken out of service. Semantics are identical to the Servlet destroy method. This method gives the handler an opportunity to clean up any resources that are being held. After this method has been called, the handle method will not be invoked again.


handle

public void handle(java.lang.Throwable throwable,
                   javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws java.lang.Throwable
Called by the Davenport servlet to allow the error handler to process an error. If the handler cannot process the error appropriately, it should be rethrown to allow processing by other entries in the handler chain. It is permissible for handlers to throw a different error, if processing the original error itself fails.

Parameters:
throwable - The error that is being presented for handling.
request - The servlet request object.
response - The servlet response object.
Throws:
java.lang.Throwable - The presented error, if it cannot be processed by this handler.


Copyright © 2004 Eric Glass