Skip to content

Instantly share code, notes, and snippets.

@tvinke
Created June 6, 2018 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvinke/01143301f45fa917076d73d9e8d0713b to your computer and use it in GitHub Desktop.
Save tvinke/01143301f45fa917076d73d9e8d0713b to your computer and use it in GitHub Desktop.
Rendering the Exception in a Grails JSON View
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