Yeah! I've found the solution.
I've just have to send ":sendError=true" with the post request.

The only documentation I've found is the javadoc [1].
I think I could add the information about that parameter at the "Special Parameters" paragraph of the "manipulating content" page [2] like:
":sendError
Setting this parameter to true (case insensitive) allows to use custom error handling as described in the Errorhandling documentation [3]"
If there is no veto I would do that.

There is already a test case for that:
ErrorHandlingTest.test_errorhandling_POST_operation_SlingPostServlet()
It sends a post to /apps/testNode and seem to use the resource type for the resolution of the error handler.

[1] - https://sling.apache.org/apidocs/sling7/org/apache/sling/servlets/post/SlingPostConstants.html#RP_SEND_ERROR

[2] - http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#special-parameters

[3] - https://sling.apache.org/documentation/the-sling-engine/errorhandling.html

Best,

Sandro

Am 06.07.15 um 16:00 schrieb Sandro Boehme:
Am 06.07.15 um 15:20 schrieb Sandro Boehme:
Hi Bertrand,

Am 06.07.15 um 14:25 schrieb Bertrand Delacretaz:
Hi Sandro,

On Mon, Jul 6, 2015 at 2:00 PM, Sandro Boehme <sandro.boe...@gmx.de>
wrote:
Am 06.07.15 um 11:16 schrieb Bertrand Delacretaz:
...debugging the
SlingServletResolver.handleError method should help as well....

The processing flow does not seem to go through this method as the
debugger
does not stop there....

The below example works for me, comparing with what you are doing
might help?

There are integration tests for this in ErrorHandlingTest [1] but they
dont seem to test the resource-specific error handlers - if you can
add some tests for that while investigating that would be great, of
course.
I'd be happy if I could do that.


$ curl -u admin:admin -Fsling:resourceType=xyz
http://localhost:8080/apps/xyz
...
     <title>Content created /apps/xyz</title>
...
$ echo '<% if(true) throw new IllegalStateException("this cannot
work"); %>' > /tmp/xyz.jsp
$ curl -u admin:admin -T/tmp/xyz.jsp
http://localhost:8080/apps/xyz/xyz.jsp
$ echo 'This is the custom error handler' >
/tmp/IllegalStateException.jsp
$ curl -u admin:admin -T /tmp/IllegalStateException.jsp
http://localhost:8080/apps/xyz/IllegalStateException.jsp
$ curl http://localhost:8080/apps/xyz.html
This is the custom error handler
Yeah, it works for me as well! Thanks for this error page example it
runs through the handleError() methods as you wrote.
I'll use the time between some family celebrations to compare with my
code and let you and the list (archive) know about the results.
As a quick check I've added your error handler jsp to the resource
folder and added the throw statement to my page. It works and shows the
custom error page! Next I will check for the right exception and
resource type in my case.

Best,

Sandro



Reply via email to