What I do is log the exception and the stack trace and then let the
super do the rest.
Since I was getting null comming up on the error page, I check the
exception message and if it is null
I at least show the name of the exception class name on the error page
(probably not too pretty but..)
The log with the stack trace should give you all the stuff you are
looking for.
mas
public class YPEDExceptionHandler extends ExceptionHandler {
private static final Log log =
LogFactory.getLog(YPEDExceptionHandler.class);
public ActionForward execute(Exception ex, ExceptionConfig ae,
ActionMapping mapping, ActionForm formInstance,
HttpServletRequest request, HttpServletResponse response)
throws ServletException {
//log the user and the stack trace then pass on to the default
exceptionHandler
HttpSession session = request.getSession();
MySessionCleanerBean user_bean = (MySessionCleanerBean)
session.getAttribute("user_bean");
if(user_bean != null){
log.fatal("user: "+ user_bean.getUser_name() + " logon_id: "+
user_bean.getLogon_id(),ex);
}else {
log.fatal("no user_bean in session", ex);
}
if(ex.getMessage() == null){
return super.execute(new
YPEDException(ex.getClass().getName(),ex), ae, mapping, formInstance,
request, response);
}
return super.execute(ex, ae, mapping, formInstance, request,
response);
}
Michael Davis wrote:
Hello,
I'm working on a struts application which has just been deployed and is
being used by a large number of users. I've got an error handler set up
using the global-exceptions tag. It sends me an email whenever it
catches an exception.
My config looks like this:
<global-exceptions>
<exception type="java.lang.Throwable"
key="error.error"
path="/err100.do"/>
</global-exceptions>
And my code does this:
Throwable e = (Throwable) request.getAttribute( Globals.EXCEPTION_KEY );
(remember that Globals.EXCEPTION_KEY is
"org.apache.struts.action.EXCEPTION").
Now my problem is that about half the time, e is null, so I can't
determine where the exception happened or even what it is.
Somehow struts is able to invoke my error handler, but sometimes does it
without setting Globals.EXCEPTION_KEY in the request. When does that
happen? How can I figure out what caused the error to happen?
thanks very much,
Michael from Ottawa
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Mark Shifman MD. Ph.D.
Yale Center for Medical Informatics
Phone (203)737-5219
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]