lib/scss_lint/config.rb in scss-lint-0.18.0 vs lib/scss_lint/config.rb in scss-lint-0.19.0

- old
+ new

@@ -1,9 +1,12 @@ require 'pathname' require 'yaml' module SCSSLint + # Raised when the configuration file is invalid for some reason. + class InvalidConfiguration < StandardError; end + # Loads and manages application configuration. class Config FILE_NAME = '.scss-lint.yml' DEFAULT_FILE = File.join(SCSS_LINT_HOME, 'config', 'default.yml') @@ -59,15 +62,19 @@ # Recursively load config files, fetching files specified by `include` # directives and merging the file's config with the files specified. def load_options_hash_from_file(file) file_contents = load_file_contents(file) - options = - if yaml = YAML.load(file_contents) - yaml.to_hash - else - {} - end + begin + options = + if yaml = YAML.load(file_contents) + yaml.to_hash + else + {} + end + rescue => ex + raise InvalidConfiguration, "Invalid configuration: #{ex.message}" + end options = convert_single_options_to_arrays(options) options = extend_inherited_configs(options, file) options = merge_wildcard_linter_options(options) options = ensure_exclude_paths_are_absolute(options, file)