Class: RulesIO::Exceptions
- Includes:
- Helpers
- Defined in:
- lib/rulesio/exceptions.rb
Instance Attribute Summary
Attributes inherited from Rack
#config_options, #controller_data, #filter_parameters
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Exceptions
constructor
A new instance of Exceptions.
- #send_event(event, env) ⇒ Object
Methods included from Helpers
#actor_for_exception, #clean_backtrace, #fileline, #from_crawler
Methods inherited from Rack
config_options, config_options=, #default_ignored_crawlers, #flush
Methods inherited from Base
Constructor Details
#initialize(app, options = {}) ⇒ Exceptions
Returns a new instance of Exceptions.
20 21 22 23 24 25 26 27 |
# File 'lib/rulesio/exceptions.rb', line 20 def initialize(app, ={}) @app, @options = app, @options[:ignore_exceptions] ||= self.class.default_ignored_exceptions @options[:ignore_crawlers] ||= default_ignored_crawlers @options[:ignore_if] ||= lambda { |env, e| false } @options[:token] ||= RulesIO.token @options[:custom_data] ||= lambda { |env| {} } end |
Class Method Details
.default_ignored_exceptions ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rulesio/exceptions.rb', line 12 def self.default_ignored_exceptions [].tap do |exceptions| exceptions << 'ActiveRecord::RecordNotFound' exceptions << 'AbstractController::ActionNotFound' exceptions << 'ActionController::RoutingError' end end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rulesio/exceptions.rb', line 29 def call(env) begin @app.call(env) rescue Exception => exception env['rulesio.exception'] = exception send_event event(env, exception), env unless should_be_ignored(env, exception) raise exception end end |
#send_event(event, env) ⇒ Object
39 40 41 42 |
# File 'lib/rulesio/exceptions.rb', line 39 def send_event(event, env) prep = prepare_event(event, env) RulesIO.post_payload_to_token prep, @options[:token] end |