Skip to content

Instantly share code, notes, and snippets.

@aadrian
Created April 21, 2015 09:33
Show Gist options
  • Save aadrian/9ebb145c8df7b4ecf1b3 to your computer and use it in GitHub Desktop.
Save aadrian/9ebb145c8df7b4ecf1b3 to your computer and use it in GitHub Desktop.
Grails Improved error messages in production mode.
<%@ page import="org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver" %>
<!DOCTYPE html>
<html>
<head>
<title><g:if env="development">Grails Runtime Exception</g:if><g:else>Error</g:else></title>
<meta name="layout" content="main">
<g:if env="development"><link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css"></g:if>
</head>
<body>
<g:if env="development">
<g:renderException exception="${exception}" />
</g:if>
<g:else>
<div class="alert alert-danger alert-dismissible" role="status" role="alert">
<strong>Error:</strong>
<hr/>
${exception.message?.encodeAsHTML()}
<%
def root = GrailsExceptionResolver.getRootCause(exception)
if (root != null && root != exception && root.message != exception.message) {
%>
<hr/>
${root.message?.encodeAsHTML()}
<%
}
%>
</div>
</g:else>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment