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.
Is there a way to suppress the stacktrace as part of REST call response? This is also a security issue wrt to revealing accidental information. I was looking if there is any configuration but haven’t found anything. My first impression is that it should be possible to handle in the exception handlers defined in “BaseRestController”, we can just introduce a property whether to pack the stacktrace inside response or not. (assuming its done by RestUtil.wrapErrorResponse). Thoughts?
I am not aware of any such configuration. Introducing a property that RestUtil.wrapErrorResponse checks to determine whether to include the stack trace or not, makes sense to me.