Created
June 6, 2018 11:58
-
-
Save tvinke/01143301f45fa917076d73d9e8d0713b to your computer and use it in GitHub Desktop.
Rendering the Exception in a Grails JSON View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response.status 500 | |
def e = request.getAttribute('javax.servlet.error.exception') | |
if (e instanceof Exception) { | |
// since its almost always an InvocationTargetException get actual cause | |
e = ((Exception)e.getCause()) | |
} | |
// us JSON API support - see http://views.grails.org/latest/#_json_api_support | |
json jsonapi.render(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment