custom error pages

This commit is contained in:
Marc Anguera Insa
2018-01-28 22:10:03 +01:00
committed by Enrico Stano
parent 79092936df
commit f2d37796c6
9 changed files with 42 additions and 77 deletions

View File

@ -895,3 +895,15 @@ form .checkbox input[type="checkbox"] {
}
}
}
.errors {
padding: 3em;
h3 {
margin-left: auto;
margin-right: auto;
max-width: 75%;
padding: 1em;
line-height: 1.6em;
}
}

View File

@ -0,0 +1,9 @@
class ErrorsController < ApplicationController
def not_found
render status: 404
end
def internal_server_error
render status: 500
end
end

View File

@ -0,0 +1,8 @@
<div class='text-center errors'>
<h1>Internal server error</h1>
<h3>
We're sorry, there seems to be an error with this request.
A notification has automatically been sent to us, and we will resolve this as soon as possible.
</h3>
<p><%= link_to 'Home', root_path, class: 'btn btn-default' %></p>
</div>

View File

@ -0,0 +1,8 @@
<div class='text-center errors'>
<h1>Not found</h1>
<h3>
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
</h3>
<p><%= link_to 'Home', root_path, class: 'btn btn-default' %></p>
</div>

View File

@ -25,5 +25,8 @@ module Timeoverflow
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
# This tells Rails to serve error pages from the app itself, rather than using static error pages in public/
config.exceptions_app = self.routes
end
end

View File

@ -78,4 +78,6 @@ Rails.application.routes.draw do
end
end
match '/404', to: 'errors#not_found', via: :all
match '/500', to: 'errors#internal_server_error', via: :all
end

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
</div>
</body>
</html>