-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch errors with custom error pages yielded w/ application layout
- Loading branch information
Showing
15 changed files
with
86 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Concerns | ||
module Errors | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
rescue_from ActiveRecord::RecordNotFound, with: :render_404 | ||
rescue_from ActionController::UnknownController, with: :render_404 | ||
rescue_from ActionController::UnknownAction, with: :render_404 | ||
rescue_from ActiveRecord::RecordInvalid, with: :render_422 | ||
rescue_from Exception, with: :render_500 | ||
end | ||
|
||
protected | ||
|
||
def render_404 | ||
render_error(code: 404) | ||
end | ||
|
||
def render_422 | ||
render_error(code: 422) | ||
end | ||
|
||
def render_500 | ||
render_error(code: 500) | ||
end | ||
|
||
def render_error(code: 404) | ||
respond_to do |format| | ||
format.html { render "errors/#{code}", status: code } | ||
format.xml { render nothing: true, status: code } | ||
format.json { render nothing: true, status: code } | ||
end | ||
end | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,13 @@ | ||
- @title = "The page you were looking for doesn't exist (404)" | ||
|
||
= render 'errors/analytics_javascript', locals: { code: 404, message: 'not found'} | ||
|
||
.error-page.text-center | ||
h1 | ||
| Looking for something? | ||
h2 | ||
| <em>Sorry,</em> this page doesn't exist. | ||
p | ||
| Try our #{link_to "homepage", root_path} to see what's new and start customizing. | ||
p.thin-bottom | ||
| Still can't find what you're looking for? #{link_to "E-mail us", 'mailto:team@fameandpartners.com'} at team@fameandpartners.com. |
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,13 @@ | ||
- @title = "The change you wanted was rejected (422)" | ||
|
||
= render 'errors/analytics_javascript', locals: { code: 422, message: 'unprocessable entity'} | ||
|
||
.error-page.text-center | ||
h1 | ||
| The change you wanted was rejected. | ||
h2 | ||
| Maybe you tried to change something you didn't have access to. | ||
p.thin-bottom | ||
= link_to 'Go to homepage', root_path | ||
p.thin-bottom | ||
| Still can't find what you're looking for? #{link_to "E-mail us", 'mailto:team@fameandpartners.com'} at team@fameandpartners.com. |
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,17 @@ | ||
- @title = "We're sorry, but something went wrong (500)" | ||
|
||
= render 'errors/analytics_javascript', locals: { code: 500, message: 'server error'} | ||
|
||
.error-page.text-center | ||
h1 | ||
| So sorry to interrupt your shopping experience. | ||
p | ||
| In the meantime, here is a $20 voucher to make up for your time - just use this code <strong>@checkout: OOPS20</strong></p> | ||
p | ||
| We should be back up in a few minutes but if you would like some further assistance, feel free to email or call us: | ||
p | ||
= link_to 'team@fameandpartners.com', 'mailto:team@fameandpartners.com' | ||
p | ||
| Our site engineers are currently making some upgrades to make it even better. | ||
p.thin-bottom | ||
= link_to 'Go to homepage', root_path |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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