Permalink
Browse files

add current file to error message

  • Loading branch information...
1 parent 826728c commit 54b229ccbf1acf9f56ca3ebc07f9e704486aafcb @grosser grosser committed Feb 13, 2010
Showing with 22 additions and 2 deletions.
  1. +11 −2 lib/less/more.rb
  2. +11 −0 test/more_test.rb
View
@@ -59,8 +59,7 @@ def generate(source)
File.read(path_to_source)
else
# less or lss file, compile it
- engine = File.open(path_to_source){|f| Less::Engine.new(f) }
- css = engine.to_css
+ css = compile(path_to_source)
css.delete!("\n") if compression # TODO: use real compression !
css = (HEADER % [File.join(source_path, source)]) << css if header
css
@@ -95,5 +94,15 @@ def all_less_files
all = Dir[File.join(Rails.root, source_path, "**", "*.{css,less,lss}")]
all.reject{|path| File.basename(path) =~ /^_/ }
end
+
+ def compile(file)
+ begin
+ engine = File.open(file){|f| Less::Engine.new(f) }
+ engine.to_css
+ rescue Exception => e
+ e.message << "\nFrom #{file}"
+ raise e
+ end
+ end
end
end
View
@@ -126,5 +126,16 @@ def assert_not_include(item, obj)
Less::More.generate_all
assert_not_include '/*', read_css('test.css')
end
+
+ should "fail with current file when encountering an error" do
+ write_less 'test.less', 'import xxxx;;;;;'
+ content = begin
+ Less::More.generate_all
+ '!no exception!'
+ rescue Exception => e
+ e.message
+ end
+ assert_include '/test.less', content
+ end
end
end

0 comments on commit 54b229c

Please sign in to comment.