NOTE: This is a legacy gem, for rails 2.x
The Super Exception Notifier (SEN) gem provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application, as well as a default set of error page templates to render based on the status code assigned to an error.
Project | Super Exception Notifier |
---|---|
gem name | super_exception_notifier |
license | MIT |
moldiness | |
version | |
dependencies | |
code quality | |
continuous integration | |
test coverage | |
homepage | https://github.com/pboling/exception_notification |
documentation | http://rdoc.info/github/pboling/exception_notification/frames |
author | Peter Boling |
Spread ~♡ⓛⓞⓥⓔ♡~ |
The gem is configurable, allowing programmers to customize (settings are per environment or per class):
git blame
output so you can get an idea of who (may) have introduced the bugThe email includes information about the current request, session, and environment, and also gives a backtrace of the exception.
This gem is based on the wonderful exception_notification plugin created by Jamis Buck. I have modified it extensively and merged many of the improvements from a dozen or so other forks. It remains a (mostly) drop in replacement with greatly extended functionality and customization options. I keep it up to date with the work on the core team's branch.
The venerable original is here
The current version of this gem is a git fork of the original and has been updated to include the latest improvements from the original, and many improvements from the other forks on github. I merge them in when I have time, and when the changes fit nicely with the enhancements I have already made.
This fork of Exception Notifier is (or was at some point) in production use on several large websites (top 5000).
[sudo] gem install super_exception_notifier
More Installation Options are here: http://wiki.github.com/pboling/exception_notification/installation
(UPGRADE NOTE: The name of the lib changed from SEN version 2.x to 3.x)
config.gem 'super_exception_notifier', :lib => "exception_notification"
More Configuration Options are here: http://wiki.github.com/pboling/exception_notification/configuration
(UPGRADE NOTE: The class invoked here changed from SEN version 2.x to 3.x)
ExceptionNotification::Notifier.configure_exception_notifier do |config|
config[:app_name] = "[MYAPP]"
config[:sender_address] = "super.exception.notifier@example.com"
config[:exception_recipients] = [] # You need to set at least one recipient if you want to get the notifications
# In a local environment only use this gem to render, never email
#defaults to false - meaning by default it sends email. Setting true will cause it to only render the error pages, and NOT email.
config[:skip_local_notification] = true
# Error Notification will be sent if the HTTP response code for the error matches one of the following error codes
config[:notify_error_codes] = %W( 405 500 503 )
# Error Notification will be sent if the error class matches one of the following error classes
config[:notify_error_classes] = %W( )
# What should we do for errors not listed?
config[:notify_other_errors] = true
# If you set this SEN will attempt to use git blame to discover the person who made the last change to the problem code
config[:git_repo_path] = nil # ssh://git@blah.example.com/repo/webapp.git
end
More Configuration Options: http://wiki.github.com/pboling/exception_notification/advanced-environment-configuration
Include the ExceptionNotification::ExceptionNotifiable mixin in whichever controller you want to generate error emails (typically ApplicationController) as below.
Specify the email recipients in your environment as above. (You may have already done this in the "Configuration in Environment (Initializer)" section above):
Make sure you have your ActionMailer server settings correct if you are using the e-mail features.
That’s it! The defaults take care of the rest.
Code:
class ApplicationController < ActionController::Base
############################################################
# ERROR HANDLING et Foo
include ExceptionNotification::ExceptionNotifiable
#Comment out the line below if you want to see the normal rails errors in normal development.
alias :rescue_action_locally :rescue_action_in_public if Rails.env == 'development'
#self.error_layout = 'errors'
self.exception_notifiable_verbose = true #SEN uses logger.info, so won't be verbose in production
self.exception_notifiable_pass_through = :hoptoad # requires the standard hoptoad gem to be installed, and setup normally
self.exception_notifiable_silent_exceptions = [Acl9::AccessDenied, MethodDisabled, ActionController::RoutingError ]
#specific errors can be handled by something else:
rescue_from 'Acl9::AccessDenied', :with => :access_denied
# END ERROR HANDLING
############################################################
...
end
ExceptionNotification::Notifier.configure_exception_notifier do |config|
config[:exception_recipients] = %w(joe@example.com bill@example.com)
end
http://wiki.github.com/pboling/exception_notification/exceptions-inside-request-cycle
There is a lot more you can configure, and do:
http://wiki.github.com/pboling/exception_notification/
Peter Boling is the original author of the code, and current maintainer.
See the Network View and the CHANGELOG
Take a look at the reek
list which is the file called REEK
and stat fixing things. Once you complete a change, run the tests:
bundle exec rake test:all
If the tests pass refresh the reek
list (need to run in Ruby 1.9.2 or 1.9.3):
bundle exec rake reek > REEK
Follow the instructions for "Contributing" below.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.
As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.
For example:
spec.add_dependency 'super_exception_notifier', '~> 3.0.14'