Errors in Sassily imported documents are displayed with the proper filename.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@447 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
1e8fb0e8d6
commit
a9e4883c68
|
@ -68,7 +68,9 @@ module Sass
|
|||
begin
|
||||
render_to_tree.to_s
|
||||
rescue SyntaxError => err
|
||||
err.add_backtrace_entry(@options[:filename])
|
||||
unless err.sass_filename
|
||||
err.add_backtrace_entry(@options[:filename])
|
||||
end
|
||||
raise err
|
||||
end
|
||||
end
|
||||
|
@ -273,11 +275,21 @@ module Sass
|
|||
nodes << Tree::ValueNode.new("@import #{filename}", @options[:style])
|
||||
else
|
||||
File.open(filename) do |file|
|
||||
new_options = @options.dup
|
||||
new_options[:filename] = filename
|
||||
engine = Sass::Engine.new(file.read, @options)
|
||||
end
|
||||
|
||||
root = engine.render_to_tree
|
||||
nodes += root.children
|
||||
begin
|
||||
root = engine.render_to_tree
|
||||
rescue Sass::SyntaxError => err
|
||||
err.add_backtrace_entry(filename)
|
||||
raise err
|
||||
end
|
||||
root.children.each do |child|
|
||||
child.filename = filename
|
||||
nodes << child
|
||||
end
|
||||
@constants.merge! engine.constants
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,9 +23,9 @@ module Sass
|
|||
# +filename+ should be the file in which the error occurred,
|
||||
# if applicable (defaults to "(sass)").
|
||||
def add_backtrace_entry(filename) # :nodoc:
|
||||
@sass_filename = filename
|
||||
@sass_filename ||= filename
|
||||
self.backtrace ||= []
|
||||
self.backtrace.unshift "#{filename || '(sass)'}:#{@sass_line}"
|
||||
self.backtrace.unshift "#{@sass_filename || '(sass)'}:#{@sass_line}"
|
||||
end
|
||||
|
||||
def to_s # :nodoc:
|
||||
|
|
|
@ -3,6 +3,7 @@ module Sass
|
|||
class Node
|
||||
attr_accessor :children
|
||||
attr_accessor :line
|
||||
attr_accessor :filename
|
||||
|
||||
def initialize(style)
|
||||
@style = style
|
||||
|
@ -23,7 +24,14 @@ module Sass
|
|||
raise SyntaxError.new('Attributes aren\'t allowed at the root of a document.', child.line)
|
||||
end
|
||||
|
||||
result += "#{child.to_s(1)}\n"
|
||||
begin
|
||||
result += "#{child.to_s(1)}\n"
|
||||
rescue SyntaxError => e
|
||||
if child.filename
|
||||
e.add_backtrace_entry(child.filename)
|
||||
end
|
||||
raise e
|
||||
end
|
||||
end
|
||||
result[0...-1]
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Sass::Tree
|
|||
super(style)
|
||||
end
|
||||
|
||||
def to_s(parent = nil)
|
||||
def to_s(tabs = 0)
|
||||
value
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue