I have created a number of entities and generated a web mvc layer including JSON controllers.
If, for any reason, code that the JSON controllers depends on fails then 2xx status code is still returned. This can be as simple as a mis-configured database resulting in a NullPointerException in generated ActiveRecord aspects or a more obscure bug in pushed-in business logic.
I propose that we catch all Exceptions and handle them with a 500 status code and brief message in the JSON payload. Returning the stack trace would IMO reveal information about the system and so therefore should not be done but at the same time something to help the client application author would be helpful. The proposal below allows the server side author to reveal a (hopefully helpful) message or none.
Existing generated example:
Proposed generated example:
In some cases there are already returned 404 codes and these should of course remain.