May 3, 2020
Estimated Post Reading Time ~

Error Handling in AEM

It’s a common requirement in AEM projects to gracefully handle errors and prevent site visitors from seeing an ugly stack trace in the unfortunate event that something goes wrong.

Obviously, in an ideal world, this would never come up because code quality guidelines will have been followed and only view logic will exist in the JSP or sightly files, as well as avoiding any null values in your model objects.

Nevertheless, AEM clients demand and deserve clean error handling. To that end, the Adobe Consulting Services common bundle has a component error handler.

AEM component error handler

The AEM error handler lets you set different error messages depending on runmode and even suppress the error handler for certain resources — for instance admin interfaces, etc, where you might want to ensure any errors are seen.

I’ve used this on one of my recent projects and it worked quite well. You can even style the output html (or point to nothing so that the error is totally invisible). The only downside I found was that if enabled during development it makes it harder for your QA team to find errors. I recommend enabling it only late in UAT or purely in production.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.