I am working on a REST backend and I have a requirement to send error information (messages together with custom application keys & codes) as JSON back to the front end.
I am not sure whether to include the JSON in the msg argument to the sendError method (from HttpServletResponse) as follows:
void sendError(int sc,
java.lang.String msg)
throws java.io.IOException
... or use the response's actual payload as follows:
response.getWriter().write(json);
Can anyone please advise as to which is the best way to proceed?