Update error logging in manager.rb to conditionally log detailed error messages based on logger level; increment version to 0.2.7

This commit is contained in:
Ari Karim 2025-05-27 14:51:18 +03:00
parent 7cb759c505
commit 99752aec39
No known key found for this signature in database
GPG Key ID: 1A5559E2E32F1805
2 changed files with 6 additions and 4 deletions

View File

@ -37,7 +37,6 @@ module Workflower
end
def possible_transitions
# @transitions.where(state: @current_state).where("sequence = :seq OR sequence = :seq_plus", seq: @current_sequence, seq_plus: @current_sequence + 1).order("sequence ASC") || []
@transitions.select do |item|
item[:state] == @current_state && (item[:sequence] == @current_sequence || item[:sequence] == @current_sequence + 1)
end
@ -62,8 +61,11 @@ module Workflower
flow.call_after_transition(@calling_model)
true
rescue Exception => e
puts "ERROR MESSAGE: #{e.message}"
puts "ERROR: #{e}"
# if the log level is set to debug, we want to log the error
logger = Workflower.configuration.logger
if logger.present? && logger.level == Logger::DEBUG
logger.debug("Error during transition: #{e.message}")
end
@calling_model.errors.add(@calling_model.workflower_state_column_name, :transition_faild)
false
end

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Workflower
VERSION = "0.2.6"
VERSION = "0.2.7"
end