error handling - Why ErrorHandler component is not registering properly in SlingMainServlet? -
i have simple component own errorhandler implementation:
@component(immediate = true) @service @properties( @property(name = "service.ranking", intvalue = 1) ) public class myerrorhandler implements errorhandler { @override public void handleerror(int status, string message, slinghttpservletrequest request, slinghttpservletresponse response) throws ioexception { handleerror(status, request, response); } @override public void handleerror(throwable throwable, slinghttpservletrequest request, slinghttpservletresponse response) throws ioexception { handleerror(505, request, response); } private void handleerror(int status, slinghttpservletrequest request, slinghttpservletresponse response) throws ioexception { if (status != 200) { try { request.getrequestdispatcher("/etc/errors/" + status + ".html").forward(request, response); } catch (servletexception e) { throw new illegalstateexception("no error pages"); } } }
if deploy component sling, nothings happen until restart of whole sling. it's not solution guess.
short explanation using errorhandler instead of handling scripts (for ask 'why didn't use overloaded script)
- writing own servlet complex easy behaviour
- scripts less maintainable java code (in sling).
Comments
Post a Comment