Permalink
Browse files

allow AC instance to be nil

  • Loading branch information...
1 parent 006be77 commit e7fa5eab8c544419a57187a2ab340fae7a51e191 @josh josh committed Jul 14, 2010
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/exception_notifier/notifier.rb
@@ -31,11 +31,16 @@ def default_options
end
end
+ class MissingController
+ def method_missing(*args, &block)
+ end
+ end
+
def exception_notification(env, exception)
@env = env
@exception = exception
@options = (env['exception_notifier.options'] || {}).reverse_merge(self.class.default_options)
- @controller = env['action_controller.instance']
+ @controller = env['action_controller.instance'] || MissingController.new
@request = ActionDispatch::Request.new(env)
@backtrace = clean_backtrace(exception)
@sections = @options[:sections]
@@ -47,7 +52,7 @@ def exception_notification(env, exception)
prefix = "#{@options[:email_prefix]}#{@controller.controller_name}##{@controller.action_name}"
subject = "#{prefix} (#{@exception.class}) #{@exception.message.inspect}"
-
+
mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
format.text { render "#{mailer_name}/exception_notification" }
end

0 comments on commit e7fa5ea

Please sign in to comment.