1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Format the Sass backtrace string a little nicer.

This commit is contained in:
Nathan Weizenbaum 2009-09-13 20:34:59 -07:00
parent a0cdac1613
commit f392867fb0
2 changed files with 7 additions and 9 deletions

View file

@ -103,14 +103,11 @@ module Sass
# @see #sass_backtrace # @see #sass_backtrace
# @return [String] # @return [String]
def sass_backtrace_str(default_filename = "an unknown file") def sass_backtrace_str(default_filename = "an unknown file")
msg = "Syntax error on line #{sass_line}" + "Syntax error: #{message}" +
" of #{sass_filename || default_filename}" + Haml::Util.enum_with_index(sass_backtrace).map do |entry, i|
": #{message}" "\n #{i == 0 ? "on" : "from"} line #{entry[:line]}" +
sass_backtrace[1..-1].each do |entry|
msg << "\n from line #{entry[:line]}" +
" of #{entry[:filename] || default_filename}" " of #{entry[:filename] || default_filename}"
end end.join
msg
end end
end end

View file

@ -55,9 +55,10 @@ class SassPluginTest < Test::Unit::TestCase
File.delete(tempfile_loc('bork1')) File.delete(tempfile_loc('bork1'))
Sass::Plugin.update_stylesheets Sass::Plugin.update_stylesheets
File.open(tempfile_loc('bork1')) do |file| File.open(tempfile_loc('bork1')) do |file|
assert_equal(<<CSS, file.read.split("\n")[0...6].join("\n")) assert_equal(<<CSS.strip, file.read.split("\n")[0...6].join("\n"))
/* /*
Syntax error on line 2 of #{template_loc('bork1')}: Undefined variable: "!bork". Syntax error: Undefined variable: "!bork".
on line 2 of #{template_loc('bork1')}
1: bork 1: bork
2: :bork= !bork 2: :bork= !bork