lib/scss_lint/engine.rb in scss-lint-0.16.1 vs lib/scss_lint/engine.rb in scss-lint-0.17.0

- old
+ new

@@ -1,8 +1,10 @@ require 'sass' module SCSSLint + class FileEncodingError < StandardError; end + # Contains all information for a parsed SCSS file, including its name, # contents, and parse tree. class Engine ENGINE_OPTIONS = { cache: false, syntax: :scss } @@ -18,8 +20,17 @@ @contents = scss_or_filename end @lines = @contents.split("\n") @tree = @engine.to_tree + rescue Encoding::UndefinedConversionError, ArgumentError => error + if error.is_a?(Encoding::UndefinedConversionError) || + error.message.include?('invalid byte sequence') + raise FileEncodingError, + "Unable to parse SCSS file: #{error.to_s}", + error.backtrace + else + raise + end end end end