Skip to content

Commit

Permalink
Fix tests and clean up import errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed May 15, 2015
1 parent 1cf2d90 commit 6df8e99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions lib/sass/tree/import_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ def import
return f if f
end

message = "File to import not found or unreadable: #{@imported_filename}.\n"
lines = ["File to import not found or unreadable: #{@imported_filename}."]

if @options[:importer]
lines << "Relative to #{@options[:filename]}"
end

if paths.size == 1
message << "Load path: #{paths.first}"
else
message << "Load paths:\n " << paths.join("\n ")
lines << "Load path: #{paths.first}"
elsif !paths.empty?
lines << "Load paths:\n #{paths.join("\n ")}"
end
raise SyntaxError.new(message)
raise SyntaxError.new(lines.join("\n"))
rescue SyntaxError => e
raise SyntaxError.new(e.message, :line => line, :filename => @filename)
end
Expand Down
4 changes: 2 additions & 2 deletions test/sass/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def test_import_from_global_load_paths
def test_nonexistent_import
assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
File to import not found or unreadable: nonexistent.sass.
Load path: #{Dir.pwd}
Relative to test_nonexistent_import_inline.sass
ERR
render("@import nonexistent.sass")
end
Expand All @@ -689,7 +689,7 @@ def test_nonexistent_import
def test_nonexistent_extensionless_import
assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
File to import not found or unreadable: nonexistent.
Load path: #{Dir.pwd}
Relative to test_nonexistent_extensionless_import_inline.sass
ERR
render("@import nonexistent")
end
Expand Down

0 comments on commit 6df8e99

Please sign in to comment.