Class: StripeModelCallbacks::BaseService

Inherits:
ServicePattern::Service
  • Object
show all
Defined in:
app/services/stripe_model_callbacks/base_service.rb

Class Method Summary collapse

Class Method Details

.reported_execute!(*args, &blk) ⇒ Object



2
3
4
5
6
7
8
9
# File 'app/services/stripe_model_callbacks/base_service.rb', line 2

def self.reported_execute!(*args, &blk)
  with_exception_notifications do
    response = execute(*args, &blk)
    raise response.errors.join(". ") unless response.success?

    return response
  end
end

.with_exception_notificationsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/stripe_model_callbacks/base_service.rb', line 11

def self.with_exception_notifications
  yield
rescue => e # rubocop:disable Style/RescueStandardError
  Rails.logger.error "ERROR: #{e.message}"

  cleaned = Rails.backtrace_cleaner.clean(e.backtrace)
  if cleaned.any?
    Rails.logger.error cleaned
  else
    Rails.logger.error e.backtrace.join("\n")
  end

  ExceptionNotifier.notify_exception(e) if Object.const_defined?("ExceptionNotifier")
  raise e
end