From c9e26197b0abbe50b029c368017243314d572884 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Mon, 12 Jul 2021 15:29:53 +0200 Subject: Logs an error in the Rails logs when installment processing fails At the moment, by default, all installment prceissing errors are swallowed and there's no way for a developer to understand what's happening. Of course they can create a custom handler with the processing_error_handler configuration provided but usually, when the first errors happen, it's too late and those errors are lost. We are not raising errors of this job because if there's a retry mechanism in place for Active Job, the installment will be reprocessed twice. Once by Active Job and once by the installment retry mechanism already provided by the extension. Logging to Rails.error is a middle-ground that allows to intercept the message of the exception. Still, creating a custom handler based on the bug tracker/exception handler used is the suggested option here. --- lib/solidus_subscriptions/configuration.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/solidus_subscriptions/configuration.rb') 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 -- cgit v1.2.3