-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KBP-140 #time 2h - Configure custom error pages
- Loading branch information
hamdibayhan
committed
Nov 13, 2017
1 parent
5abb135
commit f30c5a7
Showing
16 changed files
with
127 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
module Cybele | ||
module Helpers | ||
module ErrorPages | ||
def configure_error_pages | ||
inject_into_file 'app/controllers/application_controller.rb', | ||
template_content('error_pages/error_control.erb'), | ||
before: 'self.responder' | ||
|
||
inject_into_file 'app/controllers/application_controller.rb', | ||
template_content('error_pages/error_method.erb'), | ||
after: 'protect_from_forgery with: :exception' | ||
|
||
inject_into_file 'config/routes.rb', | ||
template_content('error_pages/error_route.erb'), | ||
before: /^end/ | ||
|
||
create_error_pages_files | ||
end | ||
|
||
private | ||
|
||
def create_error_pages_files | ||
# Server Error | ||
template 'error_pages/internal_server_error.html.haml', | ||
'app/views/errors/internal_server_error.html.haml', | ||
force: true | ||
|
||
# Not Found Error | ||
template 'error_pages/not_found.html.haml', | ||
'app/views/errors/not_found.html.haml', | ||
force: true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
en: | ||
view: | ||
view: | ||
error: | ||
internal_server_error: "We are sorry. An error occured. Our engineers are working on it. We will solve it as soon as possible." | ||
not_found: "We are sorry. Page was not found. It may have been moved." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
tr: | ||
view: | ||
view: | ||
error: | ||
internal_server_error: "Üzgünüz. Şu anda bir hata var. Mühendislerimiz bu hata üzerinde çalışma yapıyorlar. En kısa sürede çözeceğiz." | ||
not_found: "Üzgünüz. Bu sayfa bulunamadı. Taşınmış olabilir. Buraya gitmek istediğinizden emin olun." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
rescue_from Exception, with: :server_error if Rails.env.production? or Rails.env.staging? | ||
rescue_from ActiveRecord::RecordNotFound, with: :page_not_found if Rails.env.production? or Rails.env.staging? | ||
rescue_from ActionController::RoutingError, with: :page_not_found if Rails.env.production? or Rails.env.staging? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
|
||
def server_error(exception) | ||
Rollbar.error "ApplicationController#server_error --exception: #{exception}" | ||
render template: 'errors/internal_server_error', status: 500 | ||
end | ||
|
||
def page_not_found | ||
render template: 'errors/not_found', status: 404 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
if Rails.env.production? or Rails.env.staging? | ||
match '*unmatched_route', to: 'application#page_not_found', via: :all | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.well | ||
%p= t('view.internal_server_error') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.well | ||
%p= t('view.not_found') |