mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] Use the kept-around template text for error reporting.
This commit is contained in:
parent
80451b1e76
commit
5a111dd3e5
1 changed files with 4 additions and 16 deletions
|
@ -9,6 +9,7 @@ module Sass
|
|||
# when it's used as a plugin for various frameworks.
|
||||
# Currently Rails and Merb are supported out of the box.
|
||||
module Plugin
|
||||
include Haml::Util
|
||||
extend self
|
||||
|
||||
@options = {
|
||||
|
@ -143,23 +144,10 @@ END
|
|||
def header_string(e)
|
||||
return "#{e.class}: #{e.message}" unless e.is_a? Sass::SyntaxError
|
||||
|
||||
string = e.sass_backtrace_str
|
||||
return string unless e.sass_filename && File.exists?(e.sass_filename)
|
||||
|
||||
string << "\n\n"
|
||||
|
||||
min = [e.sass_line - 5, 0].max
|
||||
begin
|
||||
File.read(e.sass_filename).rstrip.split("\n")[
|
||||
min .. e.sass_line + 5
|
||||
].each_with_index do |line, i|
|
||||
string << "#{min + i + 1}: #{line}\n"
|
||||
end
|
||||
rescue
|
||||
string << "Couldn't read Sass file: #{e.sass_filename}"
|
||||
end
|
||||
|
||||
string
|
||||
e.sass_backtrace_str + "\n\n" +
|
||||
enum_with_index(e.sass_template.rstrip.split("\n")[min .. e.sass_line + 5]).
|
||||
map {|line, i| "#{min + i + 1}: #{line}"}.join("\n")
|
||||
end
|
||||
|
||||
def template_filename(name, path)
|
||||
|
|
Loading…
Add table
Reference in a new issue