You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by haric <ha...@riskmetrics.com> on 2008/06/03 19:11:22 UTC

Handling Server Errors

I am trying to write my own exception handler as per the details at
http://wiki.apache.org/myfaces/Handling_Server_Errors 

I tried to override handleException(fc,ex) method as following
public void handleException(FacesContext fc, Exception ex) throws Throwable
{
	log.error("Exception occured...", ex);
	if(ex is of sometype){
		NavigationHandler nh = fc.getApplication().getNavigationHandler();
		nh.handleNavigation(fc, null, "exceptionNavigation");
		fc.renderResponse();
	} else {
		throw ex;
	}
}

in web.xml
----------
<error-page>
 <error-code>500</error-code>
 <location>/errorDisplay.xhtml</location>
</error-page>

navigation rule
--------------
<navigation-rule>
 <navigation-case>
  <from-outcome>exceptionNavigation</from-outcome>
  <to-view-id>/errorPages/errorHtml.html</to-view-id>
 </navigation-case>
</navigation-rule>

The handleException() method gets invoked but never redirects to
errorHtml.html for if case, and it also fails for else case. If I get the
error 500 and as per web.xml it should redirect errorDisplay.xhtml instead
it shows whole stack trace on the web page.

The functionality I am looking is:
- Catch the exception in handleException() method
- log the error
- If error is certain type redirect to static html/jsf page using navigation
handler
- else throw the exception
- handle 500/404 and other exceptions using web.xml error pages
configuration
- if possible populate a bean with error messages or add messages to
FacesContext and redirect a standard jsf file where we display <h:messages>


I appreciate help on this.
-- 
View this message in context: http://www.nabble.com/Handling-Server-Errors-tp17628641p17628641.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Handling Server Errors

Posted by Daniel Niklas <co...@dniklas.de>.
Hi,


haric wrote:
> 
> I am trying to write my own exception handler as per the details at
> http://wiki.apache.org/myfaces/Handling_Server_Errors 
> 

there is written, that myfaces includes an error handling for versions 1.2.1
and 1.1.7. I would like to use this feature, but is there already a release
of 1.1.7? We're using myfaces 1.1.5, because we mustn't use SNAPSHOTS in our
own releases.

regards
Daniel

-- 
View this message in context: http://www.nabble.com/Handling-Server-Errors-tp17628641p17757221.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.