I have a class that extents the default struts ExceptionHandler ( see below).

Now, when an exception occurs in the 'Action' class..., how do i make 
sure that
the 'execute()' in 'MyExceptionHandler' is executed instaed of the 
default ExceptionHandler?


public class MyExceptionHandler extends ExceptionHandler {

        private MyChainedException tCE = null;=

        /**
         * Constructor for an external message 
         * @param tce of type MyChainedException
         *
         */
        public MyExceptionHandler(MyChainedException tce) {
                this.tCE = tce;                                 
                                                        
        }
        public ActionForward execute(Exception ex,
                                        ExceptionConfig config,
                                        ActionMapping mapping,
                                        ActionForm formInstance,
                                        HttpServletRequest request,
                                        HttpServletResponse response)
     throws ServletException {
      ActionForward forward = null;
      ActionError error = null;
      String property = null;

      /* Get the path for the forward either from the exception element
       * or from the input attribute.
       */
      String path = null;
      if (config.getPath() != null) {
       path = config.getPath();
      }else{
        path = mapping.getInput();
      }
      // Construct the forward object
      forward = new ActionForward(path);

      /* Figure out what type of exception has been thrown. The Struts
       * AppException is not being used in this example.
       */
      if( tCE instanceof MyChainedException) {
        // This is the specialized behavior
       
        Throwable t = tCE.getCause();
        String messageKey = t.getClass().getName();
        error = new ActionError( messageKey );
       
      }

      // Store the ActionError into the proper scope
      // The storeException method is defined in the parent class
      storeException(request, property, error, forward, =
config.getScope());

      return forward;
    }


}


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to