Merge pull request #10235 from colinux/page-404

Pages d'erreur personnalisées / au dsfr
This commit is contained in:
Colin Darie 2024-04-15 21:12:04 +00:00 committed by GitHub
commit e3dbbf2009
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 9056 additions and 251 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,57 @@
<svg width="80px" height="80px" viewBox="0 0 80 80" xmlns="http://www.w3.org/2000/svg">
<style>
.fr-artwork-decorative {
fill: #ECECFF;
}
.fr-artwork-minor {
fill: #E1000F;
}
.fr-artwork-major {
fill: #000091;
}
</style>
<g class="fr-artwork-decorative" id="artwork-decorative">
<path d="M69,12c0,0.55139-0.44861,1-1,1s-1-0.44861-1-1s0.44861-1,1-1S69,11.44861,69,12z M41,74
c-0.55139,0-1,0.44861-1,1s0.44861,1,1,1s1-0.44861,1-1S41.55139,74,41,74z M15,8c-0.55139,0-1,0.44855-1,1c0,0.55139,0.44861,1,1,1
s1-0.44861,1-1C16,8.44855,15.55139,8,15,8z"/>
</g>
<g class="fr-artwork-minor" id="artwork-minor">
<path d="M17,21c0,0.55139-0.44861,1-1,1s-1-0.44861-1-1s0.44861-1,1-1S17,20.44861,17,21z M20,20
c-0.55139,0-1,0.44861-1,1s0.44861,1,1,1s1-0.44861,1-1S20.55139,20,20,20z M24,20c-0.55139,0-1,0.44861-1,1s0.44861,1,1,1
s1-0.44861,1-1S24.55139,20,24,20z M62,20H32l-0.11658,0.00671C31.38599,20.06451,31,20.48718,31,21c0,0.55231,0.44769,1,1,1h30
l0.11658-0.00671C62.61401,21.93549,63,21.51282,63,21C63,20.44769,62.55231,20,62,20z M60.59998,42.20001
c0.40784,0.30591,0.5155,0.86346,0.26904,1.29498l-0.06903,0.10498l-4.30267,5.737C56.81488,49.81299,57,50.38489,57,51
c0,1.65692-1.34308,3-3,3s-3-1.34308-3-3c0-0.46307,0.10492-0.90179,0.29242-1.2934l-1.99951-1.99951
c-0.3905-0.3905-0.3905-1.02368,0-1.41418c0.36047-0.36053,0.92767-0.38818,1.32001-0.08319l0.09418,0.08319l1.99951,1.99951
C53.09821,48.10498,53.53693,48,54,48c0.31268,0,0.6142,0.04779,0.89758,0.1366l4.30243-5.73657
C59.53137,41.95819,60.1582,41.86859,60.59998,42.20001z M55,51c0-0.55231-0.44769-1-1-1s-1,0.44769-1,1s0.44769,1,1,1
S55,51.55231,55,51z"/>
</g>
<g class="fr-artwork-major" id="artwork-major">
<path d="M36.99329,62.88342L37,63c0,0.51282-0.38599,0.93549-0.88342,0.99329L36,64H12
c-0.51282,0-0.93549-0.38599-0.99329-0.88342L11,63V17c0-0.51282,0.38599-0.93549,0.88342-0.99329L12,16h54
c0.51282,0,0.93549,0.38599,0.99329,0.88342L67,17v16c0,0.55231-0.44769,1-1,1c-0.51282,0-0.93549-0.38599-0.99329-0.88342L65,33V18
H13v6h37c0.55231,0,1,0.44769,1,1c0,0.51282-0.38599,0.93549-0.88342,0.99329L50,26H13v36h23
C36.51282,62,36.93549,62.38599,36.99329,62.88342z M54,34c-9.38879,0-17,7.61121-17,17
c0,8.62091,6.41699,15.74298,14.73511,16.8504l-0.4422,0.4425l-0.08319,0.09418c-0.30499,0.39233-0.27734,0.95953,0.08319,1.32001
c0.3905,0.3905,1.02368,0.3905,1.41418,0l2-2c0.02942-0.02942,0.05701-0.06061,0.08258-0.09351
c0.05573-0.07172,0.10101-0.14996,0.13452-0.23102c0.0426-0.10284,0.0686-0.21436,0.07452-0.33105
C54.99957,67.03442,55,67.01727,55,67c0-0.13483-0.02667-0.26331-0.07501-0.38062c-0.04877-0.11877-0.1214-0.22998-0.2179-0.32648
l-2-2l-0.09418-0.08319c-0.39233-0.30499-0.95953-0.27734-1.32001,0.08319l-0.08319,0.09418
c-0.30499,0.39233-0.27734,0.95953,0.08319,1.32001l0.06,0.06012C44.33112,64.51691,39,58.38098,39,51c0-8.2843,6.7157-15,15-15
s15,6.7157,15,15c0,3.49902-1.2005,6.81122-3.3645,9.46729c-0.34882,0.42822-0.28448,1.05811,0.14368,1.40692
c0.42822,0.34882,1.05804,0.28448,1.40692-0.14374C69.63812,58.72083,71,54.9635,71,51C71,41.61121,63.38879,34,54,34z
M63.37518,62.71002c-0.5899,0.4729-1.21448,0.90076-1.86847,1.2796c-0.47791,0.27679-0.64093,0.88855-0.36414,1.36646
s0.88861,0.64093,1.36652,0.36414c0.74121-0.42932,1.44891-0.91412,2.11713-1.44983c0.43091-0.34546,0.50018-0.97479,0.15466-1.4057
C64.43542,62.43378,63.80609,62.3645,63.37518,62.71002z M62.7901,46.12402c-0.50708,0.21875-0.74078,0.80719-0.52209,1.31427
C62.74878,48.55267,63,49.75781,63,51c0,4.97058-4.02942,9-9,9s-9-4.02942-9-9s4.02942-9,9-9
c0.61743,0,1.2262,0.06201,1.82031,0.18402c0.54102,0.11096,1.06958-0.23755,1.18066-0.7785
c0.11115-0.54102-0.23749-1.06964-0.7785-1.18073C55.49622,40.07568,54.75269,40,54,40c-6.07507,0-11,4.92493-11,11
s4.92493,11,11,11s11-4.92493,11-11c0-1.51593-0.30737-2.99048-0.89557-4.354C63.88562,46.13892,63.29718,45.90521,62.7901,46.12402
z M38.11658,33.99329C38.61401,33.93549,39,33.51282,39,33c0-0.55231-0.44769-1-1-1H20l-0.11658,0.00671
C19.38599,32.06451,19,32.48718,19,33c0,0.55231,0.44769,1,1,1h18L38.11658,33.99329z M34.11658,39.99329
C34.61401,39.93549,35,39.51282,35,39c0-0.55231-0.44769-1-1-1H20l-0.11658,0.00671C19.38599,38.06451,19,38.48718,19,39
c0,0.55231,0.44769,1,1,1h14L34.11658,39.99329z M20,44l-0.11658,0.00671C19.38599,44.06451,19,44.48718,19,45
c0,0.55231,0.44769,1,1,1h12l0.11658-0.00671C32.61401,45.93549,33,45.51282,33,45c0-0.55231-0.44769-1-1-1H20z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -419,6 +419,17 @@ class ApplicationController < ActionController::Base
prepend_view_path "app/custom_views"
end
def try_nav_bar_profile_from_referrer
# detect context from referer, simple (no detection when refreshing the page)
params = Rails.application.routes.recognize_path(request&.referer)
controller_class = "#{params[:controller].camelize}Controller".safe_constantize
return if controller_class.nil?
controller_instance = controller_class.new
controller_instance.try(:nav_bar_profile)
end
# Extract a value from params based on the "path"
#
# params: { dossiers: { champs_public_attributes: { 1234 => { value: "hello" } } } }

View file

@ -0,0 +1,50 @@
# frozen_string_literal: true
class ErrorsController < ApplicationController
def nav_bar_profile = try_nav_bar_profile_from_referrer
rescue_from Exception do
# catch any error, except errors triggered by middlewares outside controller (like warden middleware)
render file: Rails.public_path.join('500.html'), layout: false, status: :internal_server_error
end
def internal_server_error
# This dynamic template is rendered when a "normal" error occurs, (ie. a bug which is 99.99% of errors.)
# However if this action fails (error in the view or in a middlewares)
# the exceptions are rescued and a basic 100% static html file is rendererd instead.
render_error 500
end
def not_found = render_error 404
def unprocessable_entity = render_error 422
def show # generic page for others errors
@status = params[:status].to_i
@error_name = Rack::Utils::HTTP_STATUS_CODES[@status]
render_error @status
end
private
def render_error(status)
respond_to do |format|
format.html { render status: }
format.json { render status:, json: { status:, name: Rack::Utils::HTTP_STATUS_CODES[status] } }
end
end
# Intercept errors in before_action when fetching user or roles
# when db is unreachable so we can still display a nice 500 static page
def current_user
super
rescue
nil
end
def current_user_roles
super
rescue
nil
end
end

View file

@ -21,16 +21,7 @@ class ReleaseNotesController < ApplicationController
render "scrollable_list" if params[:page].present?
end
def nav_bar_profile
# detect context from referer, simple (no detection when refreshing the page)
params = Rails.application.routes.recognize_path(request&.referer)
controller_class = "#{params[:controller].camelize}Controller".safe_constantize
return if controller_class.nil?
controller_instance = controller_class.new
controller_instance.try(:nav_bar_profile)
end
def nav_bar_profile = try_nav_bar_profile_from_referrer
private

View file

@ -0,0 +1,9 @@
.fr-col-12.fr-col-md-3.fr-col-offset-md-1.fr-px-6w.fr-px-md-0.fr-py-0
%svg.fr-responsive-img.fr-artwork{ xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", width: "160", height: "200", viewBox: "0 0 160 200" }
%use.fr-artwork-motif{ href: image_path("dsfr/artwork/background/ovoid.svg#artwork-motif") }
%use.fr-artwork-background{ href: image_path('dsfr/artwork/background/ovoid.svg#artwork-background') }
%g{ transform: "translate(40, 60)" }
%use.fr-artwork-decorative{ href: image_path('dsfr/artwork/pictograms/system/technical-error.svg#artwork-decorative') }
%use.fr-artwork-minor{ href: image_path('dsfr/artwork/pictograms/system/technical-error.svg#artwork-minor') }
%use.fr-artwork-major{ href: image_path('dsfr/artwork/pictograms/system/technical-error.svg#artwork-major') }

View file

@ -0,0 +1,19 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 Unexpected Error
%p.fr-text--sm.fr-mb-3w Error 500
%p.fr-text--lead.fr-mb-3w
Sorry, an error has occurred. Our teams have been notified
to resolve the issue as quickly as possible.
%p.fr-text--sm.fr-mb-5w
Try refreshing the page or try again a little later.
%br
If you need immediate assistance, please contact us.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to("Contact Us", contact_path, class: "fr-btn fr-btn--secondary")
= render partial: "artwork"

View file

@ -0,0 +1,19 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 Erreur inattendue
%p.fr-text--sm.fr-mb-3w Erreur 500
%p.fr-text--lead.fr-mb-3w
Désolé, une erreur est survenue. Nos équipes ont été averties
pour résoudre le problème le plus rapidement possible.
%p.fr-text--sm.fr-mb-5w
Essayez de rafraîchir la page ou réessayez un peu plus tard.
%br
Si le problème persiste, merci de nous contacter.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to("Contactez-nous", contact_path, class: "fr-btn fr-btn--secondary")
= render partial: "artwork"

View file

@ -0,0 +1,20 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 Page not found
%p.fr-text--sm.fr-mb-3w Error 404
%p.fr-text--lead.fr-mb-3w The page you are looking for cannot be found. We apologize for the inconvenience.
%p.fr-text--sm.fr-mb-5w
If you typed the web address in the browser, check that it is correct. The page may no longer be available.
%br
In this case, to continue your visit you can check our homepage.
%br
Otherwise, contact us so we can direct you to the correct information.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to("Homepage", root_path, class: "fr-btn")
%li
= link_to("Contact us", contact_path, class: "fr-btn fr-btn--secondary")
= render partial: "artwork"

View file

@ -0,0 +1,22 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 Page non trouvée
%p.fr-text--sm.fr-mb-3w Erreur 404
%p.fr-text--lead.fr-mb-3w La page que vous cherchez est introuvable. Excusez-nous pour la gène occasionnée.
%p.fr-text--sm.fr-mb-3w
Si vous avez tapé ladresse web dans le navigateur, vérifiez quelle est correcte. La page nest peut-être plus disponible.
%br
Dans ce cas, pour continuer votre visite vous pouvez consulter notre page daccueil.
%br
Sinon contactez-nous pour que lon puisse vous rediriger vers la bonne information.
%p.fr-text--sm.fr-mb-5w
Pour le laissez-passer A-38, relatif à lenregistrement d'une galère, veuillez vous adresser à la capitainerie au port.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to("Page daccueil", root_path, class: "fr-btn")
%li
= link_to("Contactez-nous", contact_path, class: "fr-btn fr-btn--secondary")
= render partial: "artwork"

View file

@ -0,0 +1,19 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1= @error_name
%p.fr-text--sm.fr-mb-3w Error #{@status}
%p.fr-text--lead.fr-mb-3w An error prevents this page from loading.
- if @error_name.present? # valid error code
%p.fr-text--sm.fr-mb-5w
= link_to("What does that mean?", "https://developer.mozilla.org/en/docs/Web/HTTP/Status/#{@status}", **external_link_attributes)
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to("Homepage", root_path, class: "fr-btn")
%li
= link_to("Contact us", contact_path, class: "fr-btn fr-btn--secondary")
= render partial: "artwork"

View file

@ -0,0 +1,19 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1= @error_name
%p.fr-text--sm.fr-mb-3w Erreur #{@status}
%p.fr-text--lead.fr-mb-3w Une erreur empêche le chargement de cette page.
- if @error_name.present? # valid error code
%p.fr-text--sm.fr-mb-5w
= link_to("Quest-ce que cela veut dire ?", "https://developer.mozilla.org/fr/docs/Web/HTTP/Status/#{@status}", **external_link_attributes)
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to("Page daccueil", root_path, class: "fr-btn")
%li
= link_to("Contactez-nous", contact_path, class: "fr-btn fr-btn--secondary")
= render partial: "artwork"

View file

@ -0,0 +1,24 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 The requested action has been rejected
%p.fr-text--sm.fr-mb-3w Error 422
%p.fr-text--lead.fr-mb-3w We're sorry, but we can't process your request.
%p.fr-text--sm.fr-mb-5w
This may be due to a request that cannot be processed in its current state.
%br
Go back to
= link_to("the previous page", "javascript:window.location = document.referrer", class: "fr-link")
and then try again.
%br
If the problem persists, please don't hesitate to contact us for assistance.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to 'Back', 'javascript:window.location = document.referrer', class: 'fr-btn'
%li
= link_to 'Contact us', contact_path, class: 'fr-btn fr-btn--secondary'
= render partial: "artwork"

View file

@ -0,0 +1,24 @@
%main#content{ role: "main" }
.fr-container
.fr-my-7w.fr-mt-md-12w.fr-mb-md-10w.fr-grid-row.fr-grid-row--gutters.fr-grid-row--middle.fr-grid-row--center
.fr-py-0.fr-col-12.fr-col-md-6
%h1 Laction demandée a été rejetée
%p.fr-text--sm.fr-mb-3w Erreur 422
%p.fr-text--lead.fr-mb-3w Nous sommes désolés, mais nous ne pouvons pas traiter votre requête.
%p.fr-text--sm.fr-mb-5w
Cela peut être dû à une requête qui ne peut être traitée dans son état actuel.
%br
Revenez à
= link_to("la page précédente", "javascript:window.location = document.referrer", class: "fr-link")
puis réessayez.
%br
Si le problème persiste, nhésitez pas à nous contacter pour obtenir de laide.
%ul.fr-btns-group.fr-btns-group--inline-md
%li
= link_to 'Retour', 'javascript:window.location = document.referrer', class: 'fr-btn'
%li
= link_to 'Contactez-nous', contact_path, class: 'fr-btn fr-btn--secondary'
= render partial: "artwork"

View file

@ -104,6 +104,8 @@ module TPS
config.active_record.encryption.primary_key = Rails.application.secrets.active_record_encryption.fetch(:primary_key)
config.active_record.encryption.key_derivation_salt = Rails.application.secrets.active_record_encryption.fetch(:key_derivation_salt)
config.exceptions_app = self.routes
# Copied from rgeo/activerecord-postgis-adapter
ActiveRecord::SchemaDumper.ignore_tables |= [
'geography_columns',

View file

@ -698,6 +698,11 @@ Rails.application.routes.draw do
resources :release_notes, only: [:index]
get '/404', to: 'errors#not_found'
get '/422', to: 'errors#unprocessable_entity'
get '/500', to: 'errors#internal_server_error'
get '/:status', to: 'errors#show', constraints: { status: /[4-5][0-5]\d/ }
if Rails.env.test?
scope 'test/api_geo' do
get 'regions' => 'api_geo_test#regions'

View file

@ -1,67 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>La page que vous cherchez nexiste pas (erreur 404)</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h1>La page que vous cherchez nexiste pas (erreur 404).</h1>
<p>La page que vous cherchez a sans doute changé dadresse, ou vous navez pas les droits nécessaires pour y accéder.</p>
</div>
</div>
</body>
</html>

View file

@ -1,66 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h3 {
color: #730E15;
font-weight: bold;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h3>Cette démarche n'existe pas.</h3>
<p>Merci de vérifier le lien que vous avez suivi et/ou de contacter votre administrateur.</p>
</div>
<p>Si vous êtes l'administrateur de l'application, merci de regarder les logs.</p>
</div>
</body>
</html>

View file

@ -1,59 +0,0 @@
<!DOCTYPE html>
<html lang='fr'>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
<meta content='IE=edge' http-equiv='X-UA-Compatible'>
<meta content='no-cache' name='turbolinks-cache-control'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<title>
Erreur 422 · demarches-simplifiees.fr
</title>
<style>
html,body,div,span,h1,p,a,img,table,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;}
html,body{height:100%;}
body{line-height:1;font-family:"Muli";color:#333333;font-size:16px;line-height:1.42857143;}
html{box-sizing:border-box;}
*,*::before,*::after{box-sizing:inherit;}
a{text-decoration:none;}
.page-wrapper{position:relative;min-height:100%;}
.container{padding-left:16px;padding-right:16px;max-width:700px;margin:0 auto;}
.flex{display:flex;}
.flex.align-center{align-items:center;}
.header-inner-content{padding-left:16px;padding-right:16px;max-width:1072px;margin:0 auto;display:flex;justify-content:space-between;min-height:72px;}
.new-header{background-color:#FFFFFF;}
.new-header-with-border{border-bottom:1px solid #CCCCCC;}
.header-logo{display:inline-block;margin-right:32px;}
.header-logo img{height:34px;}
@media (max-width: 1040px){
.header-logo img{height:18px;}
}
.new-h1{color:#333333;text-align:center;font-weight:bold;margin-bottom:60px;font-size:41px;margin-top:60px;}
.description{font-size: 18px; margin-bottom: 8px;}
/*! CSS Used fontfaces */
@font-face{font-family:"Muli";src:url(/fonts/muli/Muli-Regular.woff) format("woff");font-weight:normal;font-style:normal;}
</style>
</head>
<body>
<div class='page-wrapper'>
<div class='new-header new-header-with-border'>
<div class='header-inner-content'>
<div class='flex align-center'>
<a class="header-logo" href="/"><img alt='demarches-simplifiees.fr' src='/logo-ds.svg'>
</a>
</div>
</div>
</div>
<div class='container'>
<h1 class='new-h1'>Laction demandée a été rejetée.</h1>
<p class='description'>
Pas de panique, cest probablement temporaire.
</p>
<p class='description'>
Essayez de
<a href="javascript:window.location=document.referrer;">recharger la page précédente</a>,
et tout devrait rentrer dans lordre.
</p>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

2156
public/502.html Normal file

File diff suppressed because one or more lines are too long

2158
public/503.html Normal file

File diff suppressed because one or more lines are too long

2166
public/504.html Normal file

File diff suppressed because one or more lines are too long

BIN
public/fonts/Marianne-Bold.woff2 Executable file

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,59 @@
RSpec.describe ErrorsController, type: :controller do
render_views
describe 'GET #show' do
# rspec can't easily manage the exceptions_app for a real route,
# just verify the action renders correctly
let(:status_code) { 426 }
let(:status_message) { 'Upgrade Required' }
context 'HTML format' do
subject do
get :show, params: { status: status_code }, format: :html
end
it 'correctly handles and responds with an HTML response' do
subject
expect(response).to have_http_status(status_code)
expect(response.body).to include(status_message)
end
end
context 'JSON format' do
subject do
get :show, params: { status: status_code }, format: :json
end
it 'correctly handles and responds with a JSON response' do
subject
expect(response).to have_http_status(status_code)
json_response = response.parsed_body
expect(json_response['status']).to eq(status_code)
expect(json_response['name']).to eq(status_message)
end
end
end
shared_examples 'specific action' do
subject { get action_name }
it do
is_expected.to have_http_status(status_code)
end
context "404" do
let(:status_code) { 404 }
let(:action_name) { :not_found }
it_behaves_like 'specific action'
end
context "422" do
let(:status_code) { 422 }
let(:action_name) { :unprocessable_entity }
it_behaves_like 'specific action'
end
end
end

View file

@ -0,0 +1,18 @@
module WithoutDetailedExceptions
RSpec.configure do |config|
config.include self, type: :system
end
# Snippet from https://github.com/rspec/rspec-rails/issues/2024
def without_detailed_exceptions
env_config = Rails.application.env_config
original_show_exceptions = env_config['action_dispatch.show_exceptions']
original_show_detailed_exceptions = env_config['action_dispatch.show_detailed_exceptions']
env_config['action_dispatch.show_exceptions'] = true
env_config['action_dispatch.show_detailed_exceptions'] = false
yield
ensure
env_config['action_dispatch.show_exceptions'] = original_show_exceptions
env_config['action_dispatch.show_detailed_exceptions'] = original_show_detailed_exceptions
end
end

View file

@ -0,0 +1,29 @@
describe 'Errors handling', js: false do
let(:procedure) { create(:procedure) }
scenario 'bug renders dynamic 500 page' do
procedure.revisions.destroy_all # break procedure
without_detailed_exceptions do
visit commencer_path(path: procedure.path)
end
expect(page).to have_http_status(:internal_server_error)
expect(page).to have_content('une erreur est survenue')
expect(page).to have_content('Se connecter')
expect(page).to have_link('Contactez-nous')
end
scenario 'fatal error fallback to static 500 page' do
without_detailed_exceptions do
Rails.application.env_config["action_dispatch.cookies"] = "will fail"
visit commencer_path(path: procedure.path)
ensure
Rails.application.env_config.delete("action_dispatch.cookies")
end
expect(page).to have_content('une erreur est survenue')
expect(page).not_to have_content('Se connecter')
expect(page).to have_link('Contactez-nous')
end
end