Permalink
Browse files

Squashed commit of the following:

commit a36039f
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Tue Jun 21 09:25:05 2011 +0100

    merged in error page changes

commit cf43daf
Merge: 7f9ce99 2431a4e
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Tue Jun 21 09:04:24 2011 +0100

    Merge branch 'master' into error-styling

commit 7f9ce99
Merge: 9e9bdf0 2729529
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Fri Jun 17 19:20:50 2011 +0100

    Merge branch 'master' into error-styling

commit 9e9bdf0
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Fri Jun 17 07:44:00 2011 +0100

    use definition list for error details

commit 06ab871
Merge: 2f17272 a973217
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Thu Jun 16 21:47:02 2011 +0100

    Merge branch 'master' into error-styling

    Conflicts:
    	grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/RenderTagLib.groovy

commit 2f17272
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Thu Jun 16 21:43:58 2011 +0100

    add a margin above the page footer

commit fd8d59d
Author: Rob Fletcher <robert.w.fletcher@gmail.com>
Date:   Thu Jun 16 21:43:31 2011 +0100

    simplify & correct some markup in error output
  • Loading branch information...
Rob Fletcher
Rob Fletcher committed Jun 21, 2011
1 parent 2431a4e commit da90fae5a3cd6abe8c68b900edb5f739f0f6731a
@@ -24,6 +24,7 @@ import grails.util.GrailsNameUtils
import groovy.text.Template
import java.util.concurrent.ConcurrentHashMap
import javax.servlet.ServletConfig
+import org.apache.commons.lang.WordUtils
import org.codehaus.groovy.grails.commons.GrailsDomainClass
import org.codehaus.groovy.grails.io.support.GrailsResourceUtils
import org.codehaus.groovy.grails.plugins.BinaryGrailsPlugin
@@ -42,6 +43,7 @@ import org.codehaus.groovy.grails.web.sitemesh.GSPSitemeshPage
import org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter
import org.codehaus.groovy.grails.web.util.StreamCharBuffer
import org.codehaus.groovy.grails.web.util.WebUtils
+import org.springframework.http.HttpStatus
import org.springframework.util.StringUtils
/**
@@ -698,26 +700,31 @@ class RenderTagLib implements RequestConstants {
}
def currentOut = out
- currentOut << """<h2>Error ${request.'javax.servlet.error.status_code'}</h2>
-<div class="errors">
-<strong>URI:</strong> ${request.forwardURI ?: request.'javax.servlet.error.request_uri'}<br/>
+ currentOut << """<h1>Error ${prettyPrintStatus(request.'javax.servlet.error.status_code')}</h1>
+<dl class="error-details">
+<dt>URI</dt><dd>${request.forwardURI ?: request.'javax.servlet.error.request_uri'}</dd>
"""
def root = GrailsExceptionResolver.getRootCause(exception)
- currentOut << "<strong>Message:</strong> ${exception.message?.encodeAsHTML()} <br />"
+ currentOut << "<dt>Class</dt><dd>${root?.getClass()?.name ?: exception.getClass().name}</dd>"
+ currentOut << "<dt>Message</dt><dd>${exception.message?.encodeAsHTML()}</dd>"
if (root != null && root != exception && root.message != exception.message) {
- currentOut << "<strong>Caused by:</strong> ${root.message?.encodeAsHTML()} <br />"
+ currentOut << "<dt>Caused by</dt><dd>${root.message?.encodeAsHTML()}</dd>"
}
- currentOut << "</div>"
+ currentOut << "</dl>"
currentOut << errorsViewStackTracePrinter.prettyPrintCodeSnippet(exception)
def trace = errorsViewStackTracePrinter.prettyPrint(exception.cause ?: exception)
if (StringUtils.hasText(trace.trim())) {
currentOut << "<h2>Trace</h2>"
- currentOut << '<div class="stack"><pre>'
+ currentOut << '<pre class="stack">'
currentOut << trace.encodeAsHTML()
- currentOut << '</pre></div>'
+ currentOut << '</pre>'
}
}
+
+ private String prettyPrintStatus(int statusCode) {
+ "$statusCode: ${WordUtils.capitalizeFully(HttpStatus.valueOf(statusCode).name().replaceAll('_', ' '))}"
+ }
}
@@ -1,52 +1,11 @@
+<!doctype html>
<html>
- <head>
-
- <title>Grails Runtime Exception</title>
- <meta name="layout" content="main"></meta>
- <style type="text/css">
- h1, h2 {
- margin: 10px;
- }
- .exceptionMessage {
- margin: 10px;
- border: 1px solid black;
- padding: 5px;
- background-color:#E9E9E9;
- }
- .stack {
- margin:10px;
- margin-left:25px;
- margin-right:25px;
- border: 1px solid black;
- padding: 5px;
- overflow:auto;
- height: 150px;
- }
- .snippet {
- background-color:white;
- border:1px solid black;
- margin:10px;
- margin-left:25px;
- margin-right:25px;
-
- font-family:courier;
- }
- .snippet .lineNumber {
- background-color:black;
- font-weight:white;
- color:white;
- padding-left:3px;
- padding-right:3px;
- }
- .snippet .errorLine .lineNumber {
- background-color:#cc0000;
- font-weight:bold;
- color:white;
- }
- </style>
- </head>
-
- <body>
- <g:renderException exception="${exception}" />
- </body>
+ <head>
+ <title>Grails Runtime Exception</title>
+ <meta name="layout" content="main">
+ <link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css">
+ </head>
+ <body>
+ <g:renderException exception="${exception}" />
+ </body>
</html>
@@ -0,0 +1,100 @@
+h1, h2 {
+ margin: 10px 25px 5px;
+}
+
+h2 {
+ font-size: 1.1em;
+}
+
+.filename {
+ font-style: italic;
+}
+
+.exceptionMessage {
+ margin: 10px;
+ border: 1px solid #000;
+ padding: 5px;
+ background-color: #E9E9E9;
+}
+
+.error-details,
+.stack,
+.snippet {
+ margin: 0 25px 10px;
+}
+
+.stack,
+.snippet {
+ border: 1px solid #ccc;
+ -mox-box-shadow: 0 0 2px rgba(0,0,0,0.2);
+ -webkit-box-shadow: 0 0 2px rgba(0,0,0,0.2);
+ box-shadow: 0 0 2px rgba(0,0,0,0.2);
+}
+
+/* error details */
+.error-details {
+ line-height: 1.5;
+ overflow: hidden;
+ padding: 0;
+}
+
+.error-details dt {
+ clear: left;
+ float: left;
+ font-weight: bold;
+ margin-right: 5px;
+}
+
+.error-details dt:after {
+ content: ":";
+}
+
+.error-details dd {
+ display: block;
+}
+
+/* stack trace */
+.stack {
+ padding: 5px;
+ overflow: auto;
+ height: 150px;
+}
+
+/* code snippet */
+.snippet {
+ background-color: #fff;
+ font-family: monospace;
+}
+
+.snippet .line {
+ display: block;
+}
+
+.snippet .lineNumber {
+ background-color: #ddd;
+ color: #999;
+ display: inline-block;
+ margin-right: 5px;
+ padding: 0 3px;
+ text-align: right;
+ width: 3em;
+}
+
+.snippet .error {
+ background-color: #fff3f3;
+ font-weight: bold;
+}
+
+.snippet .error .lineNumber {
+ background-color: #faa;
+ color: #333;
+ font-weight: bold;
+}
+
+.snippet .line:first-child .lineNumber {
+ padding-top: 5px;
+}
+
+.snippet .line:last-child .lineNumber {
+ padding-bottom: 5px;
+}
@@ -108,6 +108,7 @@ img {
color: #000;
clear: both;
font-size: 0.8em;
+ margin-top: 1.5em;
padding: 1em;
min-height: 1em;
}
@@ -72,21 +72,21 @@ class ErrorsViewStackTracePrinter extends DefaultStackTracePrinter{
} catch (e) {
path = resource.filename
}
- """<h2>Around line ${lineNumber} of ${path}</h2>
-<div class="snippet"><pre>"""
+ """<h2>Around line ${lineNumber} of <span class="filename">${path}</span></h2>
+<pre class="snippet">"""
}
@Override
String formatCodeSnippetEnd(Resource resource, int lineNumber) {
- "</div>"
+ "</pre>"
}
@Override protected String formatCodeSnippetLine(int currentLineNumber, Object currentLine) {
- return "<div class=\"line\"><span class=\"lineNumber\">${currentLineNumber}:</span> ${currentLine.encodeAsHTML()}</div>"
+ return "<code class=\"line\"><span class=\"lineNumber\">${currentLineNumber}:</span>${currentLine.encodeAsHTML()}</code>"
}
@Override protected String formatCodeSnippetErrorLine(int currentLineNumber, Object currentLine) {
- return "<div class=\"errorLine\"><span class=\"lineNumber\">${currentLineNumber}:</span> ${currentLine.encodeAsHTML()}</div>"
+ return "<code class=\"line error\"><span class=\"lineNumber\">${currentLineNumber}:</span>${currentLine.encodeAsHTML()}</code>"
}
@Override protected int getLineNumberInfo(Throwable cause, int defaultInfo) {

0 comments on commit da90fae

Please sign in to comment.