This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Exception notifier #416
Open
nawilliams
wants to merge
10
commits into
master
Choose a base branch
from
exception-notifier
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Exception notifier #416
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
052ca76
customize public 500 page for parking
nawilliams 41fae2d
add exception notifier gem and config
nawilliams 5189be7
remove rescuing in application controller
nawilliams eb21fb3
Merge branch 'remove-probable' of github.com:umts/golf-cart-rentals i…
nawilliams 86dfb3a
Merge branch 'master' of github.com:umts/golf-cart-rentals into excep…
nawilliams 4a8b161
gold -> golf
nawilliams 16a0311
cleanup .keep files
nawilliams 075e25b
remove errormailer and replace with exception notifier
nawilliams 752fc32
Merge branch 'master' of github.com:umts/golf-cart-rentals into excep…
nawilliams f675b18
remove old notifier config
nawilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
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 |
---|---|---|
|
@@ -15,7 +15,6 @@ class ApplicationController < ActionController::Base | |
# Set auto papertrail | ||
before_action :set_paper_trail_whodunnit | ||
|
||
rescue_from RuntimeError, Exception, with: :render_500 unless Rails.env.development? | ||
rescue_from ActiveRecord::RecordNotFound, with: :render_404 unless Rails.env.development? | ||
rescue_from MissingUserError, with: :render_401 | ||
|
||
|
@@ -30,20 +29,6 @@ def render_404 | |
end | ||
end | ||
|
||
def render_500(error) | ||
# make sure to log the error | ||
logger.error error.message | ||
logger.error error.backtrace.join("\n") | ||
|
||
# send email to IT | ||
send_error_email(error) | ||
|
||
respond_to do |format| | ||
format.html { render template: 'errors/500.html.erb', status: 500 } | ||
format.all { render body: nil, status: 500 } | ||
end | ||
end | ||
|
||
def render_401 | ||
render template: 'errors/401.html.erb', layout: false, status: 401 | ||
end | ||
|
@@ -88,13 +73,6 @@ def has_permission? | |
|
||
private | ||
|
||
def send_error_email(error) | ||
user = @current_user | ||
serializable_error = { class: error.class.to_s, message: error.message, trace: error.backtrace } | ||
ErrorMailer.error_email('[email protected]', request.fullpath, user, | ||
serializable_error).deliver_later | ||
end | ||
|
||
def check_permission | ||
return if has_permission? | ||
flash[:warning] = 'Your account does not have access to this page' | ||
|
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
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 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 |
---|---|---|
|
@@ -100,21 +100,14 @@ | |
port: 25 | ||
} | ||
|
||
config.middleware.use ExceptionNotification::Rack, | ||
:email => { | ||
:email_prefix => "[ERROR] ", | ||
:sender_address => %{"notifier" <[email protected]>}, | ||
:exception_recipients => %w{[email protected]} | ||
}, | ||
:slack => { | ||
:webhook_url => "https://hooks.slack.com/services/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", | ||
:channel => "#probably-exceptions", | ||
:additional_parameters => { | ||
:icon_url => "http://image.jpg", | ||
:mrkdwn => true | ||
} | ||
} | ||
|
||
# Inventory api url | ||
config.inventory_api_uri = 'https://rentalapi.parking.umass.edu/v1/' # not sure what this is yet | ||
end | ||
|
||
GolfCartRentals::Application.config.middleware.use ExceptionNotification::Rack, | ||
email: { | ||
email_prefix: "Golf-Cart-Rentals Exception: ", | ||
sender_address: %{"Golf-Cart-Rentals" <[email protected]>}, | ||
exception_recipients: %w{[email protected]} | ||
|
||
} |
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,66 +1,95 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>We're sorry, but something went wrong (500)</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; | ||
} | ||
<head> | ||
<title>We're sorry, but something went wrong (500)</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 { | ||
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); | ||
} | ||
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; | ||
} | ||
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> | ||
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/500.html --> | ||
<div class="dialog"> | ||
<div> | ||
<h1>We're sorry, but something went wrong.</h1> | ||
<body> | ||
<!-- This file lives in public/500.html --> | ||
<div class="dialog"> | ||
<div> | ||
<h1> | ||
An error occured processing your request. A message has been sent to | ||
IT. | ||
</h1> | ||
</div> | ||
<p> | ||
Please contact UMass Parking Services using the contact information | ||
below to report any additional information. | ||
</p> | ||
<p> | ||
This site is maintained by UMass Amherst Parking Services<br /> | ||
413.577.PARK | | ||
<a href="https://parking.umass.edu/" rel="nofollow" | ||
>Parking Home Page</a | ||
> | ||
| | ||
<a href="mailto:[email protected]?Subject=Issue:" target="_top" | ||
>Report An Error</a | ||
> | ||
<br /> | ||
© | ||
<script> | ||
document.write(new Date().getFullYear());</script | ||
>2019 | ||
<a href="http://www.umass.edu/" rel="nofollow" | ||
>University of Massachusetts Amherst</a | ||
> | ||
| | ||
<a href="http://www.umass.edu/umhome/policies/" rel="nofollow" | ||
>Site Policies</a | ||
> | ||
</p> | ||
</div> | ||
<p>If you are the application owner check the logs for more information.</p> | ||
</div> | ||
</body> | ||
</body> | ||
</html> |
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.
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just use the
config
declared above, as in all our other apps. No need to re-declare theGolfCartRentals::Application
here.