Currently the error response is ad-hoc an JSON data structure. It would be good to adopt a more formal standard such as application/vnd.error+json.
It would also be good to move the error response creation into a role so people can replace it with whatever they need.