module FailbotRails::ActionControllerUtilities

Private Instance Methods

_failbot_rails() click to toggle source
# File lib/failbot_rails.rb, line 112
def _failbot_rails
  context = {
    :controller => params[:controller],
    :action => params[:action],
    :user => lambda {
      respond_to?(:current_user) &&
        current_user.respond_to?(:login) &&
        current_user.login
    },
  }

  # allow overriding context by defining ApplicationController#failbot_context
  if respond_to?(:failbot_context) && failbot_context.respond_to?(:to_hash)
    context.merge!(failbot_context.to_hash)
  end

  Failbot.push(::FailbotRails._failbot_safe_context(context))
end
failbot(e, context={}) click to toggle source
# File lib/failbot_rails.rb, line 98
def failbot(e, context={})
  if e.kind_of?(ActionView::TemplateError) && e.respond_to?(:original_exception)
    # exceptions raised from views are wrapped in TemplateError. This is the
    # most annoying thing ever.
    e = e.original_exception
  end

  if e.respond_to?(:info) && e.info.is_a?(Hash)
    context = e.info.merge(context || {})
  end

  Failbot.report(e, ::FailbotRails._failbot_safe_context(context))
end