ErrorhandlingPage added by Felix MeschbergerHandling ErrorsThe Sling Engine includes support for handling uncaught Throwable}}s as well as rendering custom HTTP status code pages. This is implemented by expecting a (single) {{org.apache.sling.engine.servlets.ErrorHandler service to which handling of uncaught {{Throwable}}s and HTTP status responses are delegated. The Sling Servlet Resolver bundle implements this interface by providing an elaborate mechanism to find the correct error handling script or servlet using the same algorithms as are used to select the scripts or servlets to handle regular requests. This page provides more information on how error handler scripts are selected and what is provided out of the box. Handling HTTP Status CodesThe Sling engine implements the HttpServletResponse.sendError methods by calling the ErrorHandler.handleError(int status, String message, SlingHttpServletRequest request, SlingHttpServletResponse response) method. The Servlet Resolver bundle implementation looks up a script to handle the status code as follows:
Examples:
Handling Uncaught ThrowablesWork in Progress To handle uncaught Throwables the simple name of the Throwable class is used as the Servlet name. Similarly to the Java try-catch clauses the class hierarchy is supported. That is to handle an uncaught FileNotFoundException, the names FileNotFoundException, IOException, Exception, Throwable are checked for a Servlet and the first one found is then used. Again, the Serlvet may be a Servlet registered as an OSGi service or may be a plain script stored in the JCR repository or provided through some custom Resource provider.
Change Notification Preferences
View Online
|
Add Comment
|
- [CONF] Apache Sling Website > Errorhandling confluence
- [CONF] Apache Sling Website > Errorhandling confluence
- [CONF] Apache Sling Website > Errorhandling confluence
- [CONF] Apache Sling Website > Errorhandling confluence
