From 35226f4b7351116788df4b58a091061466908c8e Mon Sep 17 00:00:00 2001 From: Ben Lovell Date: Thu, 9 Jan 2025 15:18:37 +0000 Subject: [PATCH] Use MoneyHelper branded error pages --- app/controllers/errors_controller.rb | 13 ++ .../errors/internal_server_error.html.erb | 12 ++ app/views/errors/not_found.html.erb | 12 ++ .../errors/unprocessable_entity.html.erb | 12 ++ config/application.rb | 2 + config/routes.rb | 4 + public/404.html | 140 ------------------ public/422.html | 140 ------------------ public/500.html | 140 ------------------ 9 files changed, 55 insertions(+), 420 deletions(-) create mode 100644 app/controllers/errors_controller.rb create mode 100644 app/views/errors/internal_server_error.html.erb create mode 100644 app/views/errors/not_found.html.erb create mode 100644 app/views/errors/unprocessable_entity.html.erb delete mode 100644 public/404.html delete mode 100644 public/422.html delete mode 100644 public/500.html diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 000000000..6783a0c84 --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,13 @@ +class ErrorsController < ApplicationController + def not_found + render status: :not_found + end + + def internal_server_error + render status: :internal_server_error + end + + def unprocessable_entity + render status: :unprocessable_entity + end +end diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb new file mode 100644 index 000000000..7c1cdf17e --- /dev/null +++ b/app/views/errors/internal_server_error.html.erb @@ -0,0 +1,12 @@ +
+

We're sorry. Something seems to have gone wrong.

+

This is a problem at our end. Try again later and we will hope to have fixed it.

+ + +
diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 000000000..3b1b25c9e --- /dev/null +++ b/app/views/errors/not_found.html.erb @@ -0,0 +1,12 @@ +
+

We're sorry. We can't find that page.

+

Please check the address you entered or try again later and you should be able to find it.

+ + +
diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb new file mode 100644 index 000000000..3ac1e5475 --- /dev/null +++ b/app/views/errors/unprocessable_entity.html.erb @@ -0,0 +1,12 @@ +
+

We're sorry. We can't process that data.

+

You have entered data that we don't know what to do with, or that we can't process. Please go back and try again later.

+ + +
diff --git a/config/application.rb b/config/application.rb index 681e3f873..cd78f624f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,6 +10,8 @@ module Rad class Application < Rails::Application config.load_defaults 5.1 + config.exceptions_app = self.routes + config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" config.active_record.belongs_to_required_by_default = false diff --git a/config/routes.rb b/config/routes.rb index 2c5fc84a2..40b601b3e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,10 @@ Rails.application.routes.draw do devise_for :users + get '/404', to: 'errors#not_found' + get '/500', to: 'errors#internal_server_error' + get '/422', to: 'errors#unprocessable_entity' + if Rails.env.staging? mount Lockup::Engine, at: '/lockup' end diff --git a/public/404.html b/public/404.html deleted file mode 100644 index a88cd859f..000000000 --- a/public/404.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - 404 Page Not Found - - - - - - - - -
-

We're sorry. We can't find that page.

-

Please check the address you entered or try again later and you should be able to find it.

- - -
- - - - diff --git a/public/422.html b/public/422.html deleted file mode 100644 index d2b88db12..000000000 --- a/public/422.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - 422 Unprocessable Entity - - - - - - - - -
-

We're sorry. We can't process that data.

-

You have entered data that we don't know what to do with, or that we can't process. Please go back and try again later.

- - -
- - - - diff --git a/public/500.html b/public/500.html deleted file mode 100644 index b9df9c6ac..000000000 --- a/public/500.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - 500 Internal Server Error. - - - - - - - - -
-

We're sorry. Something seems to have gone wrong.

-

This is a problem at our end. Try again later and we will hope to have fixed it.

- - -
- - - -