Hi,

I try to implement an application specific exception handling. Therefor I 
created a class that extends ExceptionHandler and my own Exception class that 
has variables for holding an error code and the filename where the exception 
occured.

When I generate a NullPointerException I generate a new object of my exception 
class an throw it. Unfortunately, in the exception handler class I only see 
an object of class Exception. So, I'm not able to get the error code and the 
filename from the exception object. When I try to cast the exception 
explicitly to my exception class I get a ClassCastException. 

How can I get an object of my own exception in the exception handler?

Regards,
Ralf.

struts-config.xml:

  <global-exceptions>
    <exception handler="de.fortu.actions.FortuExceptionHandler"
                           type="java.lang.Exception"
                           key="global.error"
                           path="/jsp/error/error.jsp"
                           scope="request" />
  </global-exceptions>

ExceptionHandler Class:

public class FortuExceptionHandler extends ExceptionHandler 
{

  public ActionForward execute (Exception ex, ExceptionConfig config,   
                               ActionMapping mapping, ActionForm formInstance, 
                                HttpServletRequest request, 
                                HttpServletResponse response)
  throws ServletException 
 {
    String property = null;
    String path = null;

    if(config.getPath() != null)
      path = config.getPath();
    else
      path = mapping.getInput();

    ActionForward forward = new ActionForward(path);

    ActionError error = new ActionError("global.error.nosession");
    
    storeException (request, property, error, forward, config.getScope());
    return forward;
  }
}

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

Reply via email to