Module: Bosh::Monitor::YamlHelper
- Included in:
- Runner
- Defined in:
- lib/bosh/monitor/yaml_helper.rb
Instance Method Summary collapse
Instance Method Details
#load_yaml_file(path, expected_type = Hash) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bosh/monitor/yaml_helper.rb', line 4 def load_yaml_file(path, expected_type = Hash) raise(ConfigError, "Cannot find file '#{path}'") unless File.exists?(path) yaml = Psych.load_file(path) if expected_type && !yaml.is_a?(expected_type) raise ConfigError, "Incorrect file format in '#{path}', #{expected_type} expected" end yaml rescue SystemCallError => e raise ConfigError, "Cannot load YAML file at '#{path}': #{e}" end |