Class: ExceptionHandler::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_handler/parser.rb

Overview

Message

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Message

Init



7
8
9
# File 'lib/exception_handler/parser.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Error



12
13
14
15
16
17
18
19
20
21
# File 'lib/exception_handler/parser.rb', line 12

def call(env)
  @app.call(env)

rescue Exception => exception
  request = ActionDispatch::Request.new(env)
  controller = env['action_controller.instance']

  ExceptionHandler::Parser.new(exception, request, controller).save unless self.ignore?(exception, request)
  raise exception
end

#ignore?(exception, request, ignored = {}) ⇒ Boolean

Ignore

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/exception_handler/parser.rb', line 24

def ignore?(exception, request, ignored = {})
  ignored[:errors] = [ActionController::RoutingError, AbstractController::ActionNotFound, ActiveRecord::RecordNotFound]
  ignored[:bots]   = /\b(Baidu|Gigabot|Googlebot|libwww-per|lwp-trivial|msnbot|SiteUptime|Slurp|Wordpress|ZIBB|ZyBorg|Yandex|Jyxobot|Huaweisymantecspider|ApptusBot)\b/i

  return true if ignored[:errors].include?(exception.class) && request.referer.blank?
  return true if request.user_agent =~ ignored[:bots]
end