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:
nex3 2007-03-25 04:57:03 +00:00
parent 1e8fb0e8d6
commit a9e4883c68
4 changed files with 27 additions and 7 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -9,7 +9,7 @@ module Sass::Tree
super(style)
end
def to_s(parent = nil)
def to_s(tabs = 0)
value
end
end