Skip to content

Commit

Permalink
catch runtime error in calculate expression service
Browse files Browse the repository at this point in the history
  • Loading branch information
nudded committed Jan 27, 2025
1 parent 5bf371c commit f88369a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/services/events/calculate_expression_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def call
event.properties[field_name] = value

result
rescue RuntimeError => e
result.service_failure!(code: :expression_evaluation_failed, message: e.message)
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def estimate_charge_fees(charge)
properties = charge_filter&.properties || charge.properties

# Todo: perhaps this should live in its own service
Events::CalculateExpressionService.call!(organization:, event:)
Events::CalculateExpressionService.call(organization:, event:)
billable_metric = charge.billable_metric
units = BigDecimal(event.properties[charge.billable_metric.field_name] || 0)
units = BillableMetrics::Aggregations::ApplyRoundingService.call!(billable_metric:, units:).units
Expand Down

0 comments on commit f88369a

Please sign in to comment.