redesign of the error page
did
committed Jan 12, 2017
commit 23304e6f4adcd3d2240175662fe5f62b0ea65c7a
Showing 2
changed files with
71 additions
and 19 deletions
Gemfile
+1
-1
| @@ | @@ -8,7 +8,7 @@ gem 'rb-fsevent', '~> 0.9.1' |
| # Development | |
| # gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '257047b', require: false | |
| # gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: 'f4ff435', require: false | |
| - | gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'd75b646', require: false |
| + | gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'b1feb8b', require: false |
| # Local development | |
| # gem 'locomotivecms_coal', path: '../gems/coal', require: false | |
locomotive/wagon/middlewares/error_page.rb b/lib/locomotive/wagon/middlewares/error_page.rb
+70
-18
| @@ | @@ -16,6 +16,7 @@ module Locomotive::Wagon |
| self.next | |
| rescue StandardError => error | |
| @error = error | |
| + | puts error.inspect |
| log_error | |
| render_error_page | |
| end | |
| @@ | @@ -31,6 +32,9 @@ module Locomotive::Wagon |
| def render_error_page | |
| _template = ERB.new(template, nil, '-') | |
| render_response(_template.result(binding)) | |
| + | rescue Exception => e |
| + | puts e.inspect |
| + | 'Unknown error' |
| end | |
| def template | |
| @@ | @@ -40,27 +44,75 @@ module Locomotive::Wagon |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| <head> | |
| <title>Wagon - Rendering error</title> | |
| + | <link href="https://fonts.googleapis.com/css?family=Muli:300,400,700" rel="stylesheet" /> |
| + | <style> |
| + | body { margin: 0px; padding: 0px; font-family: 'Muli', sans-serif; } |
| + | div { padding: 20px; } |
| + | h1 { |
| + | margin: 0px; |
| + | padding: 20px 0px; |
| + | text-align: center; |
| + | color: #fff; |
| + | background: #E1535E; |
| + | } |
| + | h2 { |
| + | font-size: 40px; |
| + | text-align: center; |
| + | } |
| + | h3 { |
| + | text-transform: uppercase; |
| + | font-weight: normal; |
| + | } |
| + | h3 strong { font-weight: bold; text-transform: none; } |
| + | p { |
| + | font-weight: 300; |
| + | line-height: 22px; |
| + | margin: 20px 20px 30px; |
| + | } |
| + | pre { |
| + | margin: 20px 20px 30px; |
| + | padding: 20px 0px 20px 0px; |
| + | border-left: 4px solid #CACACA; |
| + | background: #FAFAFA; |
| + | box-sizing: border-box; |
| + | line-height: 20px; |
| + | } |
| + | pre strong { |
| + | margin-right: 20px; |
| + | } |
| + | </style> |
| </head> | |
| <body> | |
| - | <h1>Arrrghhhh, we could not render page</h1> |
| - | <h2><%= @error.message %></h2> |
| - | |
| - | <h3>File: <%= @error.respond_to?(:file) ? @error.file : '?' %></h3> |
| - | |
| - | <h3>Code</h3> |
| - | <% if @error.respond_to?(:code_lines) %> |
| - | <pre> |
| - | <% @error.code_lines.each do |(line, statement)| -%> |
| - | <strong><%= line %></strong> <%= statement %> |
| - | <% end -%> |
| - | </pre> |
| - | <% else %> |
| - | <p><i>No code</i></p> |
| - | <% end %> |
| - | |
| - | <h3>Back trace</h3> |
| - | <%= @error.backtrace.join("<br/>") %> |
| + | <h1>Arrrghhhh, we could not render your page</h1> |
| + | |
| + | <div> |
| + | <h2><%= @error.message %></h2> |
| + | |
| + | <% if @error.respond_to?(:file) %> |
| + | <h3>File:</h3> |
| + | <p><%= @error.file %></p> |
| + | <% end %> |
| + | |
| + | <% if @error.respond_to?(:action) %> |
| + | <h3>Action:</h3> |
| + | <p><%= @error.action %></p> |
| + | <% end %> |
| + | |
| + | <% if @error.respond_to?(:code_lines) %> |
| + | <h3>Code</h3> |
| + | <pre> |
| + | <% @error.code_lines.each do |(line, statement)| -%> |
| + | <strong><%= line %></strong> <%= ERB::Util.html_escape(statement) %> |
| + | <% end -%> |
| + | </pre> |
| + | <% else %> |
| + | <p><i>No code</i></p> |
| + | <% end %> |
| + | |
| + | <h3>Backtrace</h3> |
| + | <p><%= @error.backtrace.join("<br/>") %></p> |
| + | </div> |
| </body> | |
| </html>} | |