OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#66093] Move Dentaku-error handling into the ErrorHandler
Tobias Dillmann6dd29458be1e
diff --git a/app/models/acts_as_customizable/calculated_value.rb b/app/models/acts_as_customizable/calculated_value.rbindex 5b1f3b54216..d9fc7af1277 100644--- a/app/models/acts_as_customizable/calculated_value.rb+++ b/app/models/acts_as_customizable/calculated_value.rb@@ -75,21 +75,9 @@ module ActsAsCustomizable::CalculatedValuevalue.is_a?(Numeric) ? value : nilend- errors = calculation.transform_values do |value|- case value- when Dentaku::ZeroDivisionError- :zero_division- when Dentaku::ArgumentError- :missing_value- when Dentaku::UnboundVariableError- [:unbound_variable, value.unbound_variables]- when Numeric- # Calculation succeeded -> no error- nil- else- :unknown- end- end.compact+ errors = calculation.reject do |_, value|+ value.is_a?(Numeric)+ end{ result:, errors: }enddiff --git a/app/models/calculated_values/error_handler.rb b/app/models/calculated_values/error_handler.rbindex 9b912b8a804..b1865ae941e 100644--- a/app/models/calculated_values/error_handler.rb+++ b/app/models/calculated_values/error_handler.rb@@ -80,14 +80,14 @@ module CalculatedValuescustom_field_id = to_id(cf_id)case error- in :zero_division+ when Dentaku::ZeroDivisionErrorErrorContext.new(custom_field_id:, error_code: "ERROR_MATHEMATICAL")- in :missing_value+ when Dentaku::ArgumentErrorbuild_missing_value_error_context(custom_field_id)- in [:unbound_variable, disabled_fields]+ when Dentaku::UnboundVariableErrorErrorContext.new(custom_field_id:,error_code: "ERROR_DISABLED_VALUE",- missing_custom_field_ids: disabled_fields.map { to_id(it) })+ missing_custom_field_ids: error.unbound_variables.map { to_id(it) })elseErrorContext.new(custom_field_id:, error_code: "ERROR_UNKNOWN")end