Handle errors page through controller ErrorsController

This commit is contained in:
Jean-Baptiste Bellet
2022-08-08 15:36:46 +02:00
parent 47c07831c1
commit 60a5bf682b
4 changed files with 5 additions and 122 deletions

View File

@@ -124,4 +124,9 @@ Openfoodnetwork::Application.routes.draw do
# Mount Spree's routes
mount Spree::Core::Engine, :at => '/'
# Errors controller
match '/404' => 'errors#not_found', via: :all
match '/500' => 'errors#internal_server_error', via: :all
match '/422' => 'errors#unprocessable_entity', via: :all
end

View File

@@ -1,41 +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;
font-family: arial, sans-serif;
}
div.dialog {
width: 600px;
margin: auto;
}
@media only screen
and (min-width: 320px)
and (max-width: 568px) {
div.dialog, div.dialog img {
width: 95%;
}
}
div.dialog h1 {
font-size: 1.8em;
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<a href="/" ><img src="/500.jpg" /></a>
<h1>Oops! Page not found.</h1>
<b>Please try again</b>
<p>This might be a temporary problem. Please click the back button to return to the previous screen or go back to <a class="go_home" href="/">Home</a> and try again.</p>
<b>Contact support</b>
<p>If the problem persists or is urgent, please tell us about it. Find our contact details from the global <a href="https://openfoodnetwork.org/ofn-local/" target="blank">Open Food Network Local page</a>.</p>
<p>It really helps us if you can give as much detail as possible about what the missing page is about.</p>
</div>
</body>
</html>

View File

@@ -1,38 +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: 2em auto 0 auto;
}
a.go_home {
font-size: 100%;
color: black;
line-height: 1.5em;
text-decoration: none;
border-bottom: 1px dotted black;
padding: 0 0.2rem;
}
a.go_home:hover, a.go_home:focus, a.go_home:active{
background: #8f301d;
color: white;
border-bottom: none;
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<a href="/" ><img src="/422.jpg" /></a>
<p>The change you wanted was rejected. Maybe you tried to change something you don't have access to.
<br><h3><a class="go_home" href="/" >Return home</a></h3>
</p>
</div>
</body>
</html>

View File

@@ -1,43 +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;
font-family: arial, sans-serif;
}
div.dialog {
width: 600px;
margin: auto;
}
@media only screen
and (min-width: 320px)
and (max-width: 568px) {
div.dialog, div.dialog img {
width: 95%;
}
}
div.dialog h1 {
font-size: 1.8em;
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<a href="/" ><img src="/500.jpg" /></a>
<h1>We're sorry, but something went wrong.</h1>
<b>Please try again</b>
<p>This might be a temporary problem. Please click the back button to return to the previous screen or go back to <a class="go_home" href="/">Home</a> and try again.</p>
<b>We're on it</b>
<p>If you have seen this problem before, we probably already know about it and are working on a fix. We record all the errors that come up.</p>
<b>Contact support</b>
<p>If the problem persists or is urgent, please tell us about it. Find our contact details from the global <a href="https://openfoodnetwork.org/ofn-local/" target="blank">Open Food Network Local page</a>.</p>
<p>It really helps us if you can give as much detail as possible about what you were doing when this error occurred.</p>
</div>
</body>
</html>