Module: ExecuteWithRescue::Mixins::WithAirbrake

Extended by:
ActiveSupport::Concern
Defined in:
lib/execute_with_rescue/mixins/with_airbrake.rb

Instance Method Summary collapse

Instance Method Details

#_execute_with_rescue_airbrake_adaptersObject

For pushing and popping the adapters



61
62
63
# File 'lib/execute_with_rescue/mixins/with_airbrake.rb', line 61

def _execute_with_rescue_airbrake_adapters
  @_execute_with_rescue_airbrake_adapters ||= []
end

#_execute_with_rescue_current_airbrake_adapterObject



65
66
67
68
# File 'lib/execute_with_rescue/mixins/with_airbrake.rb', line 65

def _execute_with_rescue_current_airbrake_adapter
  _execute_with_rescue_airbrake_adapters.last ||
    fail(ExecuteWithRescue::Errors::NoAirbrakeAdapter)
end

#notify_by_airbrake_or_raise(ex) ⇒ Object

Call this if you have some custom handling for some classes Override this if you have some additional operation like logging for all kinds of error inherited from ‘StandardError`

Examples:

Add default parameters when rescuing AR Invalid Error

class SomeWorker
  rescue_from ActiveRecord::RecordInvalid,
              with: :notify_by_airbrake_or_raise_ar_invalid_error

  def notify_by_airbrake_or_raise_ar_invalid_error(ex)
    add_default_airbrake_notice_parameters({
      active_record_instance: ex.record.inspect,
      active_record_instance_errors: ex.record.errors.inspect,
    })
    notify_by_airbrake_or_raise(ex)
  end
end


55
56
57
58
# File 'lib/execute_with_rescue/mixins/with_airbrake.rb', line 55

def notify_by_airbrake_or_raise(ex)
  _execute_with_rescue_current_airbrake_adapter.
    notify_or_raise(ex)
end