module ServiceExtend::Handler

Public Instance Methods

call() click to toggle source
Calls superclass method
# File lib/service_extend/handler.rb, line 4
def call
  if defined?(::Rails::Engine) && defined?(::ActiveRecord)
    begin
      super
    rescue ServiceError => e
      @error = e
    rescue ActiveRecord::RecordNotFound => e
      @error = ServiceError.new(:record_not_found, error_message: e.message)
      @error.set_backtrace(e.backtrace)
    rescue Exception => e
      @error = ServiceError.generate_from_exception(e)
    end
  else
    begin
      super
    rescue ServiceError => e
      @error = e
    rescue Exception => e
      @error = ServiceError.generate_from_exception(e)
    end
  end
end