[Sass] Print the Sass backtrace on error for the sass executable.
This commit is contained in:
parent
616a00cea6
commit
f4380e655a
|
@ -12,6 +12,10 @@ especially when importing files.
|
||||||
All imports will now show up in the Ruby backtrace,
|
All imports will now show up in the Ruby backtrace,
|
||||||
with the proper filename and line number.
|
with the proper filename and line number.
|
||||||
|
|
||||||
|
In addition, when the `sass` executable encounters an error,
|
||||||
|
it now prints the filename where the error occurs,
|
||||||
|
as well as a backtrace of Sass imports.
|
||||||
|
|
||||||
## [2.2.3](http://github.com/nex3/haml/commit/2.2.3)
|
## [2.2.3](http://github.com/nex3/haml/commit/2.2.3)
|
||||||
|
|
||||||
Sass 2.2.3 prints line numbers for warnings about selectors
|
Sass 2.2.3 prints line numbers for warnings about selectors
|
||||||
|
|
|
@ -264,7 +264,7 @@ END
|
||||||
output.close() if output.is_a? File
|
output.close() if output.is_a? File
|
||||||
rescue ::Sass::SyntaxError => e
|
rescue ::Sass::SyntaxError => e
|
||||||
raise e if @options[:trace]
|
raise e if @options[:trace]
|
||||||
raise "Syntax error on line #{get_line e}: #{e.message}"
|
raise e.sass_backtrace_str("standard input")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,22 @@ module Sass
|
||||||
return nil if super.nil?
|
return nil if super.nil?
|
||||||
sass_backtrace.map {|h| "#{h[:filename] || "(sass)"}:#{h[:line]}"} + super
|
sass_backtrace.map {|h| "#{h[:filename] || "(sass)"}:#{h[:line]}"} + super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a string representation of the Sass backtrace.
|
||||||
|
#
|
||||||
|
# @param default_filename [String] The filename to use for unknown files
|
||||||
|
# @see #sass_backtrace
|
||||||
|
# @return [String]
|
||||||
|
def sass_backtrace_str(default_filename = "an unknown file")
|
||||||
|
msg = "Syntax error on line #{sass_line}" +
|
||||||
|
" of #{sass_filename || default_filename}" +
|
||||||
|
": #{message}"
|
||||||
|
sass_backtrace[1..-1].each do |entry|
|
||||||
|
msg << "\n from line #{entry[:line]}" +
|
||||||
|
" of #{entry[:filename] || default_filename}"
|
||||||
|
end
|
||||||
|
msg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The class for Sass errors that are raised due to invalid unit conversions
|
# The class for Sass errors that are raised due to invalid unit conversions
|
||||||
|
|
Loading…
Reference in New Issue