Method: Puppet::Util::Yaml.safe_load_file_if_valid
- Defined in:
- lib/puppet/util/yaml.rb
.safe_load_file_if_valid(filename, allowed_classes = []) ⇒ Object
Safely load the content from a file as YAML if contents are in valid format. This method does not raise error but returns ‘nil` when invalid file is given.
55 56 57 58 59 60 |
# File 'lib/puppet/util/yaml.rb', line 55 def self.safe_load_file_if_valid(filename, allowed_classes = []) safe_load_file(filename, allowed_classes) rescue YamlLoadError, ArgumentError, Errno::ENOENT => detail Puppet.debug("Could not retrieve YAML content from '#{filename}': #{detail.}") nil end |