Sha256: 183641804638592dd4ae22bd39b00ae0a9822954bdd97b48c22ce8a176d83538

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

require 'active_support/concern'
require 'active_support/core_ext/module/delegation.rb'

module ExceptionHandling
  module LoggingMethods # included on models and controllers
    extend ActiveSupport::Concern

    protected

    delegate :log_error_rack, :log_warning, :log_info, :log_debug, :escalate_error, :escalate_warning, :ensure_escalation, :alert_warning, to: ExceptionHandling

    # TODO: delegate log_error as well
    def log_error(exception_or_string, exception_context = '')
      controller = self if respond_to?(:request) && respond_to?(:session)
      ExceptionHandling.log_error(exception_or_string, exception_context, controller)
    end

    def ensure_safe(exception_context = "")
      yield
    rescue => ex
      log_error ex, exception_context
      nil
    end

    def ensure_alert(*args)
      ExceptionHandling.ensure_alert(*args) do
        yield
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exception_handling-2.7.0.pre.1 lib/exception_handling/logging_methods.rb