summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
blob: d6fcf7e75178f78a004b81f69726f3c93bb79342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module SolidusSubscriptions
  module ProcessingErrorHandlers
    class RailsLogger
      def self.call(exception, installment = nil)
        new(exception, installment).call
      end

      def initialize(exception, installment = nil)
        @exception = exception
        @installment = installment
      end

      def call
        Rails.logger.error("Error processing installment with ID=#{installment.id}:") if installment
        Rails.logger.error(exception.message)
      end

      private

      attr_reader :exception, :installment
    end
  end
end