Module: Datadog::CI::Utils::Json

Defined in:
lib/datadog/ci/utils/json.rb

Class Method Summary collapse

Class Method Details

.read_file(file_path) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/datadog/ci/utils/json.rb', line 9

def self.read_file(file_path)
  unless File.exist?(file_path)
    Datadog.logger.debug { "JSON file not found: #{file_path}" }
    return nil
  end

  JSON.parse(File.read(file_path))
rescue JSON::ParserError, SystemCallError => e
  Datadog.logger.debug { "Failed to load JSON file #{file_path}: #{e.message}" }
  nil
end