1
votes

As defined here http://adobe-consulting-services.github.io/acs-aem-commons/features/errorpagehandler.html I am trying to confgure error pages for my application. Here is what I have done:

1) Created 404.jsp and default.jsp at /apps/sling/servlet/errorhandler as defined on the page.

2) Added below widget to the advanced tab:

<errorpages
    jcr:primaryType="cq:Widget"
    path="/apps/acs-commons/components/utilities/errorpagehandler/dialog/errorpages.infinity.json"
    xtype="cqinclude"/>

3) Created /apps//config/com.adobe.acs.commons.errorpagehandler.impl.ErrorPageHandlerImpl.xml

with the following properties:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig"
    prop.enabled="{Boolean}true"
    prop.error-page.fallback-name="500"
    prop.error-page.system-path="/content/error"
    prop.error-page.extension="html"
    ttl="{Long}300"/>

4) Created /content/myapp/en/errors using a fresh template. The template has only a parsys. Inside the /content/myapp/en/errors, I have created page 404 and 500 using the same template. In the video it is shown that when the speaker opens the pages 404.html and 500.html created under geometrixx from siteadmin he is able to see appropriate error messages. What I am not able to understand is that if my template consists of only a parsys how will the 404 and 500 pages show the error messge. From where are those messages being generated ? Am I missing something here ? Do I have to create any component ?

5) In the Page Properties of the page /content/myapp/en , I have configured /content/myapp/en/errors as the Error Page. To generate a 404 error when I try to access the URL /content/myapp/ent.html instead of /content/myapp/en.html it throws a

 No resource found

Cannot serve request to /content/myapp/ent.html in /apps/sling/servlet/errorhandler/404.jsp

Not sure how do I get he nice looking pages as shown in the video.

5) How can I make the error messages authorable ?

Thanks in advance

4

4 Answers

1
votes

No need to follow so many steps. The ACS commons package with the error handler is available as a package. Down load this package from This ACS commons git hub site

The name of the file is --> acs-aem-commons-content-1.9.6.zip(2.3 MB). Then just create sling:OsgiConfig node in your /apps/myapp/config with name --> com.adobe.acs.commons.wcm.impl.ComponentErrorHandlerImpl. Then put the below configuration into the node.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
    xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="sling:OsgiConfig"
    prop.edit.enabled="{Boolean}true"
    prop.edit.html="/apps/acs-commons/components/utilities/component-error-handler/edit.html"
    prop.preview.enabled="{Boolean}false"
    prop.preview.html="/apps/acs-commons/components/utilities/component-error-handler/preview.html"
    prop.publish.enabled="{Boolean}false"
    prop.publish.html="/dev/null"
	/>

Below is the configure component in crxde lite after the configuration you can this is how crxde lite looks

Thats all. You need not do anything else.You will get proper error pages or messages for all 500 or 404 errors

1
votes

As you said in 5th step In the Page Properties of the page /content/myapp/en , you have configured /content/myapp/en/errors as the Error Page. This error pages are work for for child pages under this path /content/myapp/en . In your case it will be work for all the childs under /content/myapp/en/*.html Ex. It will work for /content/myapp/en/{invalidurl}.html

0
votes

The question was about the page error handler, the answer is provided about in: component error handler. These two different things altogether.

the CEH handles the exception in component scope where as EPH handles it in request scope when component fails and the exception is not handled by CEH and response is written as 500, it will be handled by EPH

0
votes

For point 4) The template has only a parsys.

Yes you have to configure the components and place them in the parsys as you would do for your content pages that will display in case of error pages. The error handler gives you the flexibility to modify what shows up in error pages by keeping them authorable. You can change the look and feel of error pages for each of the valid HTTP errors.

For example, whatever I create in my content/error/404.html page will show up when the actual 404 is returned by the errorhandler.

enter image description here

In case of an invalid URL: enter image description here

For point 5) In the Page Properties of the page /content/myapp/en , I have configured /content/myapp/en/errors as the Error Page. To generate a 404 error when I try to access the URL /content/myapp/ent.html instead of /content/myapp/en.html it throws an error.

The mistake that you did here was that you are trying to access a parent page url. One solution would be to place the custom error pages at a level higher than the content pages for your website.

You can do this more than once. As in keep separate error page for global errors, some other for myapp, some others for myapp/en and so on.

So if you have seen there is a tab in page properties where you can author the error pages root url. This can be leveraged to give different URLs as per requirement.

For example,

  1. If you want an error page for /content/myapp/ent.html then place a separate set of error handler pages at content/myapp in addition to those at content/myapp/en.
  2. Then goto myapp.html and in Page Properties override the error page url to content/myapp/error. enter image description here
  3. For each parent whenever you need a separate error page url author those in page properties.

So now I have two renditions of my error page: One for content/myapp and other for content/myapp/en

As shown below:

path - /content/test.html (Global) enter image description here

path - /content/myapp/ent.html (Myapp): enter image description here

enter image description here

Config node:

enter image description here

Sample template to show the difference:

enter image description here