Expand my Community achievements bar.

SOLVED

Dispatcher is not catching 500 errors

Avatar

Level 2

Hi, 

 

I´m in an AEM cloud project, I´m trying to configure the dispatcher to redirect to specific error pages (client don´t want to handle this on sling). I want to handle errors 404 and 500 for now.

 

I have the next config in dispatcher:

 

<IfModule disp_apache2.c>
# Enabled to allow rewrites to take affect and not be ignored by the dispatcher module
DispatcherUseProcessedURL On
# Default setting to allow all errors to come from the aem instance
DispatcherPassError 1
</IfModule>

# Error pages handling
# Set ERRORDOCS based on URL
SetEnvIfNoCase Request_URI "^/([a-z]{2})/.*" ERRORDOCS=$1/errors

# Set to default if not exists
SetEnvIfNoCase ERRORDOCS ^\s*$ ERRORDOCS=errors

<LocationMatch />
# Redirect 500 y 404 errors to the corresponding pages based on ERRORDOCS
ErrorDocument 500 /%{ENV:ERRORDOCS}/500
ErrorDocument 404 /%{ENV:ERRORDOCS}/404
</LocationMatch>
</VirtualHost>

 

The issue is that for 404 errors this config is working properly, redirecting me to the proper 404 page, but if I force a component inside a page to throw a NullPointer (for example) it is not working anymore. It is showing me the default cloud internal error page. However in the console I can see that it is actually resolving a 500. Attached example:

 

user5741_0-1711095504157.png

 

Has anyone any idea of what is happening, or has anyone facing something similar in the past? It seems that the dispatcher config of "ErrorDocument 500" is not catching this errors, I don´t know why. I would like any kind of help anyone can give me.

 

Thank you all!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @user5741 
There must be a config at CDN, that is triggering the OOTB error page instead of your custom 500 page.

 

Can you please check https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aemaacs-error-handling-usi... 



Arun Patidar

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @user5741 
You need to handle the 500 error in your component properly using try and catch.

 

until the response status is not set 500 for page from server, you would not get the 500 response code and hence the page would be serve with 200.



Arun Patidar

Avatar

Level 2

Hi @arunpatidar ,

 

Thank you for your response, as you can see in the console screenshot the page is already a 500 response.

Avatar

Community Advisor

Hi @user5741 

Can you please check the network tab and check the response status?



Arun Patidar

Avatar

Level 2

Sure,

 

Here it is, as you can see the homepage (that´s is on / ) is on 500.

 

user5741_0-1711099916709.png

 

Avatar

Correct answer by
Community Advisor

Hi @user5741 
There must be a config at CDN, that is triggering the OOTB error page instead of your custom 500 page.

 

Can you please check https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aemaacs-error-handling-usi... 



Arun Patidar