I am writing an Alfresco Web Script that will be consumed by external computers.
When I throw a WebScriptException, I would like the error 500 to come with an error page in JSON, rather than HTML, so that the external computers can parse it. Right now I am getting this:
How to get JSON instead?
I see that some Web Scripts manage to produce error pages as JSON (for error 401 though, so probably before the Web Script actually gets called):
You can create a freemarker dedicated for each status code. If you go to this web page http://docs.alfresco.com/5.2/concepts/ws-component-name.html and scroll to "FreeMarker Templates - Response status", you can see some examples.
Quoting as of 5.2: