Display 500 error | Community
Skip to main content
Level 3
May 27, 2025
Solved

Display 500 error

  • May 27, 2025
  • 2 replies
  • 646 views

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

Best answer by giuseppebaglio

hi @pnagy

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

 
 

2 replies

giuseppebaglio
giuseppebaglioAccepted solution
Level 10
May 27, 2025

hi @pnagy

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

 
 
pnagyAuthor
Level 3
May 27, 2025

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

Monendra_Singh
Level 3
May 27, 2025

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.