Skip to content

Commit

Permalink
(SUP-5232) Added error handling to JSON conversion of metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Johnston committed Jan 6, 2025
1 parent ea98c34 commit 05cf01b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion files/pe_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ def post_endpoint(url, body)
end

def retrieve_additional_metrics(url, _metrics_type, metrics)
metrics_output = post_endpoint(url, metrics.to_json)
begin
json_data = metrics.to_json
rescue StandardError => e
STDERR.puts 'Failed to convert metrics to JSON.'
STDERR.puts "Error: #{e.message}"
STDERR.puts e.backtrace
return []
end

metrics_output = post_endpoint(url, json_data)
return [] if metrics_output.empty?

# For a status other than 200 or 404, add the HTTP code to the error array
Expand Down

0 comments on commit 05cf01b

Please sign in to comment.