summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions
diff options
context:
space:
mode:
authorAlberto Vena <kennyadsl@gmail.com>2021-07-20 16:30:43 +0200
committerGitHub <noreply@github.com>2021-07-20 16:30:43 +0200
commitc6c9fea5898530405dff44f5603e9191a679d1a6 (patch)
treee7e511496ad1bb7b0b0d32607cf634332192d69b /lib/solidus_subscriptions
parent662719693c9f369cd9176e432ab3d4a554822751 (diff)
parent0317e228bc79c13667940203add35fa13fac21f1 (diff)
Merge pull request #235 from solidusio-contrib/kennyadsl/log-installments-errors-by-defaultHEADmaster
Log installments errors by default
Diffstat (limited to 'lib/solidus_subscriptions')
-rw-r--r--lib/solidus_subscriptions/configuration.rb9
-rw-r--r--lib/solidus_subscriptions/engine.rb1
-rw-r--r--lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb25
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/solidus_subscriptions/configuration.rb b/lib/solidus_subscriptions/configuration.rb
index 9d6c3d2..350fabc 100644
--- a/lib/solidus_subscriptions/configuration.rb
+++ b/lib/solidus_subscriptions/configuration.rb
@@ -4,14 +4,14 @@ module SolidusSubscriptions
class Configuration
attr_accessor(
:maximum_total_skips, :maximum_reprocessing_time, :churn_buster_account_id,
- :churn_buster_api_key, :clear_past_installments, :processing_error_handler
+ :churn_buster_api_key, :clear_past_installments
)
attr_writer(
:success_dispatcher_class, :failure_dispatcher_class, :payment_failed_dispatcher_class,
:out_of_stock_dispatcher, :maximum_successive_skips, :reprocessing_interval,
:minimum_cancellation_notice, :processing_queue, :subscription_line_item_attributes,
- :subscription_attributes, :subscribable_class, :order_creator_class
+ :subscription_attributes, :subscribable_class, :order_creator_class, :processing_error_handler
)
def success_dispatcher_class
@@ -34,6 +34,11 @@ module SolidusSubscriptions
@out_of_stock_dispatcher_class.constantize
end
+ def processing_error_handler
+ @processing_error_handler ||= 'SolidusSubscriptions::ProcessingErrorHandlers::RailsLogger'
+ @processing_error_handler.constantize
+ end
+
def maximum_successive_skips
@maximum_successive_skips ||= 1
end
diff --git a/lib/solidus_subscriptions/engine.rb b/lib/solidus_subscriptions/engine.rb
index 0f274d8..2d361cf 100644
--- a/lib/solidus_subscriptions/engine.rb
+++ b/lib/solidus_subscriptions/engine.rb
@@ -6,6 +6,7 @@ require 'solidus_subscriptions'
require 'solidus_subscriptions/permitted_attributes'
require 'solidus_subscriptions/configuration'
require 'solidus_subscriptions/processor'
+require 'solidus_subscriptions/processing_error_handlers/rails_logger'
module SolidusSubscriptions
class Engine < Rails::Engine
diff --git a/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb b/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
new file mode 100644
index 0000000..d6fcf7e
--- /dev/null
+++ b/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
@@ -0,0 +1,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