summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
diff options
context:
space:
mode:
authorAlberto Vena <kennyadsl@gmail.com>2021-07-12 15:29:53 +0200
committerAlberto Vena <kennyadsl@gmail.com>2021-07-13 16:22:59 +0200
commitc9e26197b0abbe50b029c368017243314d572884 (patch)
tree751072edbfae746e21045bdc027606c48c2670d2 /lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
parent662719693c9f369cd9176e432ab3d4a554822751 (diff)
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.
Diffstat (limited to 'lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb')
-rw-r--r--lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb23
1 files changed, 23 insertions, 0 deletions
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..d209123
--- /dev/null
+++ b/lib/solidus_subscriptions/processing_error_handlers/rails_logger.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module SolidusSubscriptions
+ module ProcessingErrorHandlers
+ class RailsLogger
+ def self.call(exception)
+ new(exception).call
+ end
+
+ def initialize(exception)
+ @exception = exception
+ end
+
+ def call
+ Rails.logger.error exception.message
+ end
+
+ private
+
+ attr_reader :exception
+ end
+ end
+end