views:

106

answers:

2

I've installed super_exception_notifier by running:

sudo gem install super_exception_notifier

and then I've tried enabling it in my project (which already has mailing working, since it sends emails for other purposes) like this. On environment.rb I added

# Notification configuration
require 'exception_notifier'
ExceptionNotifier.configure_exception_notifier do |config|
  config[:exception_recipients] = %w([email protected])
  config[:notify_error_codes]   = %W( 404 405 500 503 )
end

and on my application_controller.rb I have:

require 'exception_notifiable'

class ApplicationController < ActionController::Base
  include ExceptionNotifiable

Am I missing something? because no matter what error I generate. Either a 404, a route error, division by zero in a controller or in the console, in development or production mode, I get no emails and no error messages or anything at all.

Any ideas?

A: 

Maybe it has has something to do with this: http://github.com/pboling/exception%5Fnotification

Email notifications will only occur when the IP address is determined not to be local. You can specify certain addresses to always be local so that you’ll get a detailed error instead of the generic error page. You do this in your controller (or even per-controller).

consider_local "64.72.18.143", "14.17.21.25"

You can specify subnet masks as well, so that all matching addresses are considered local:

consider_local "64.72.18.143/24"

The address "127.0.0.1" is always considered local. If you want to completely reset the list of all addresses (for instance, if you wanted "127.0.0.1" to NOT be considered local), you can simply do, somewhere in your controller:

local_addresses.clear
MattMcKnight
Well, I did tried that remotely to my server in production; and I would expect that console errors are always sent as they are always local anyway.
J. Pablo Fernández
A: 

Pablo,

Thanks for pointing out the holes in the documentation. I will setup a blank rails project and then clearly enumerate the steps. I have already updated the Readme in response to the tickets you created on github.

To help with you immediate problem this is how I have it setup, (and it works for me! :) Not all parts of this are essential to it working, but I'm not editing it (much), so you can see what I have:

I have this in my environment.rb:

  config.load_paths += %W( #{RAILS_ROOT}/app/middlewares #{RAILS_ROOT}/app/mixins #{RAILS_ROOT}/app/classes #{RAILS_ROOT}/app/mailers #{RAILS_ROOT}/app/observers )

I have an initializer in config/initializers/super_exception_notification.rb

  #The constants ($) are set in the config/environments files.
  ExceptionNotifier.configure_exception_notifier do |config|
    config[:render_only] = false
    config[:skip_local_notification] = false
    config[:view_path] = 'app/views/errors'
    config[:exception_recipients] = $ERROR_MAIL_RECIPIENTS
    config[:send_email_error_codes] = $ERROR_STATUS_SEND_EMAIL
    #config[:sender_address] = %("RINO #{(defined?(Rails) ? Rails.env : RAILS_ENV).humanize} Error" )
    config[:sender_address] = "[email protected]"
    config[:email_prefix] = "[RINO #{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} ERROR] "
  end

Then in my application.rb I have this:

  include ExceptionNotifiable, CustomEnvironments
  alias :rescue_action_locally :rescue_action_in_public if Environments.local_environments.include?(Rails.env)
  self.error_layout = 'errors'
  self.exception_notifiable_verbose = false
  self.exception_notifiable_silent_exceptions = [MethodDisabled]

Then I also have this mixin in my app/mixins directory:

module CustomEnvironments

  module Environments
    def self.local_environments
      %w( development test )
    end

    def self.deployed_environments
      %w( production staging )
    end
  end
end

One other thing, this plugin does not abolish the rails standard which is that things in public are trump. So if you have 404.html in public, it will always get rendered for 404's.

  • Peter
Peter H. Boling