How to stop displaying stacktrace and http error reports generated by openmrs and display instead custom error response


Whenever we try to hit any custom module invalid endpoint , or whenever any internal error occurs in those cases OpenMRS returns complete stacktrace of error in form json body or an http error report page such as 500 error html page or 403 forbidden error html page. We want to stop showing those pages and instead want to handle with help of custom error json body, and return it finally to the api client.

How to proceed on this, we also weren’t able to find any stop printing stack trace property which we can use.

We tried implementing a error filter in our module so it was able to handle the 500 json based error but in some cases we found openMRS was overriding it returning a 500 html error report page and also the 403 forbidden error which our filter wasn’t able to override.

Any solution on openMRS core level such that we only receive a custom error json response to our client after trapping the actual json/html error body.

Urgent help required. @dkayiwa

OpenMRS team, any update on this?

@helpdesk1 @dkayiwa Can you please help with this.

Kindly share the entire error logs using pastebin.