Expand my Community achievements bar.

SOLVED

AEM:: Error Handling using the acs-aem-commons package

Avatar

Level 4

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/<myapp>/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

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

In the video, his error pages show the appropriate message because of the template he used when he created the pages. The template had the title component already on it, so when the page loads it will display the page title. If you use the same page template that you are using for the rest of your site, it will keep the same design are those pages. These pages work the same as another page in your site, so you can add a text component to them, and type any error message that you want displayed.

The reason you are getting the no resource found, is because the error page configuration was configured at the /content/myapp/en level, so anything on that page level will not use the custom error page, only pages that are children of the en.html page. So, if you had a page here /content/myapp/en/example.html and you tried accessing /conent/myapp/en/exampletttt.html, then the custom error page should show up.

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

In the video, his error pages show the appropriate message because of the template he used when he created the pages. The template had the title component already on it, so when the page loads it will display the page title. If you use the same page template that you are using for the rest of your site, it will keep the same design are those pages. These pages work the same as another page in your site, so you can add a text component to them, and type any error message that you want displayed.

The reason you are getting the no resource found, is because the error page configuration was configured at the /content/myapp/en level, so anything on that page level will not use the custom error page, only pages that are children of the en.html page. So, if you had a page here /content/myapp/en/example.html and you tried accessing /conent/myapp/en/exampletttt.html, then the custom error page should show up.

Avatar

Level 4

Thanks for the response. So does it mean that to show errors at /content/myapp/en level, I need to create a separate set of error pages and for the errors at   /content/myapp/en/example.html there will be a separate set of error pages ?

Also, to handle error codes like 500, 403 etc, I understand I will need to create cq:Pages. But do I need to create more JSPs like 500.jsp, 403.jsp under /apps/sling/servlet/errorhandler ?

And I may be naive in asking this, but what role are the JSPs under /apps/sling/servlet/errorhandler playing apart from overlaying the default error pages under /libs. Is it somehow related to the cq:Pages created for the different categories of errors ?

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----