Expand my Community achievements bar.

SOLVED

Display 500 error

Avatar

Level 4

Hi,

I have a custom AEM endpoint returning some json content. In some cases when there is some content related issue, I would like to return a 500 with a custom json body. It is working good on my local but when running the same on cloud it is displaying an AEM error page with the text "Unexpected Error: Looks like we are having some issues with our service. We are working hard to bring it online again.".
How could I configure AEM / dispatcher so that it just simply displays the content I send in my response? I have found several documents / entries on creating custom error pages (tried to set e.g. DispatcherPassError) but no luck.
So is there a way to return the response of my /bin/.... endpoint as it is to the client on cloud? The same is working with e.g. 404 error code.

Thanks,
Peter

1 Accepted Solution

Avatar

Correct answer by
Level 9

hi @pnagy

You can try setting the response header x-aem-error-pass=true, as outlined in the documentation.

Screenshot 2025-05-27 at 14.52.36.png

 
 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 9

hi @pnagy

You can try setting the response header x-aem-error-pass=true, as outlined in the documentation.

Screenshot 2025-05-27 at 14.52.36.png

 
 

Avatar

Level 4

Thanks @giuseppebag, it is working as expected.
I missed that, exactly what I was looking for.

Avatar

Level 4

To ensure your custom JSON error is returned and not replaced by an AEM error page:

-Set Dispatcher to pass errors for your endpoints.
-Avoid AEM's default error handling for that path by ensuring all logic/output is handled in your servlet.