Table of Contents
The ExceptionHandlingService handles the exceptions that bubbled outside of Nuxeo. It allows to define handlers to forward to an error page with adequate messages and logs.
It is composed of 3 extension points: the errorHandlers configures the handlers, the requestdump configures the way the request will be written to error log and listener allows to set a listener to the process so state can be restore in case of error.
This service is only available in Nuxeo 5.2
The request dump extension point allows to contribute a RequestDumper class. It takes a request as parameter and output the string that will be written to error log. The default contribution is:
<extension target="org.nuxeo.ecm.platform.web.common.exceptionhandling.service.ExceptionHandlingService" point="requestdump"> <requestdump class="org.nuxeo.ecm.platform.web.common.exceptionhandling.service.DefaultRequestDumper" /> </extension>
It writes the attributes of the request.
The listener extension point allows to contribute a listener that will be called during the different phase of the exception handling. The default contribution does nothing (this is use by WebEngine):
<extension target="org.nuxeo.ecm.platform.web.common.exceptionhandling.service.ExceptionHandlingService" point="listener"> <listener class="org.nuxeo.ecm.platform.web.common.exceptionhandling.service.NullExceptionHandlingListener" /> </extension>
This contribution is over written in the module nuxeo-platform-webapp-core with:
<extension target="org.nuxeo.ecm.platform.web.common.exceptionhandling.service.ExceptionHandlingService" point="listener"> <listener class="org.nuxeo.ecm.webapp.shield.SeamExceptionHandlingListener" /> </extension>
This listener restore the faces/seam context before to write the attributes (use by NuxeoEP).
The errorhandlers extension point allows to configure the different handler. General attribute are:
errorhandlers attributes
The message bundle to use. The default bundle used in Nuxeo is messages.
The name of the logger to use. Default is nuxeo-error-log. If you change this value, you need to update your logging configuration.
The page to which you will be forwarded if no page is defined in the handler configuration.
The attributes for each handler are:
A regular expression, if matched the Exception we are handling, this handler will be used. The last handler should use ".*" as a Regular Expression.
The key, in the message bundle defined in the general attribute, of the message that will be output to the user.
The error page we should forward to. If not defined we will forward to the default error page as defined in the general attribute.
The status code set to the response. If none the default code will be set.
The default configuration is:
<extension target="org.nuxeo.ecm.platform.web.common.exceptionhandling.service.ExceptionHandlingService" point="errorhandlers"> <errorHandlers bundle="messages" loggerName="nuxeo-error-log" defaultpage="nuxeo_error.jsp"> <handlers> <handler error=".*NoSuchDocumentException" message="Error.Document.Not.Found" code="404"/> <handler error="javax.jcr.ItemNotFoundException" message="Error.Document.NotFound" code="404"/> <handler error=".*NoSuchPropertyException" message="Error.Document.NoSuchProperty"/> <handler error=".*SecurityException" message="Error.Insuffisant.Rights"/> <handler error=".*" message="Error.Unknown"/> </handlers> </errorHandlers> </extension>