Created
May 28, 2013 08:41
-
-
Save dmons/5661389 to your computer and use it in GitHub Desktop.
Integration ExceptionNotification into app
This file contains hidden or 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
if Rails.env.production? | |
rescue_from Exception, with: :render_500 | |
rescue_from ActiveRecord::RecordNotFound, ActionController::RoutingError, :with => :render_404 | |
else | |
rescue_from ActiveRecord::RecordInvalid, :with => :show_errors | |
end | |
def render_500(exception) | |
respond_to do |format| | |
ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver | |
format.html { render :layout=>'500',:nothing => true, status: 500 } | |
format.all { render nothing: true, status: 500} | |
end | |
end | |
def show_errors(e) | |
I18n.with_locale(:en) do | |
e.record.valid? | |
raise e.record.errors.full_messages.join("\n ") | |
end | |
end |
This file contains hidden or 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
gem 'exception_notification', :require => 'exception_notifier' |
This file contains hidden or 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
config.middleware.use ExceptionNotifier, | |
:email_prefix => "[StyleUp Exception ] ", | |
:sender_address => %{"styleup_bot" <[email protected]>}, | |
:exception_recipients => %w{[email protected] [email protected]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment