lib/asset_compiler.rb in vitrine-0.0.29 vs lib/asset_compiler.rb in vitrine-0.0.30
- old
+ new
@@ -41,10 +41,11 @@
Vitrine.compile_sass(scss_source_path, get_public)
rescue Errno::ENOENT # Missing SCSS
forward_or_halt "No such CSS or SCSS file found"
rescue Exception => e # CSS syntax error or something alike
cache_bust!
+ print_compilation_error(e)
# Add a generated DOM element before <body/> to inject
# a visible error message
error_tpl = 'body:before {
background: white; padding: 3px; font-family: monospaced; color: red;
font-size: 14px; content: %s }'
@@ -97,10 +98,12 @@
rescue Exception => e # CS syntax error or something alike
# Ensure the response with the exception gets reloaded on next request
cache_bust!
+ print_compilation_error(e)
+
# Inject the syntax error into the browser console
console_message = 'console.error(%s)' % [e.class, "\n", "--> ", e.message].join.inspect
# Avoid 500 because it plays bad with LiveReload
halt 200, console_message
end
@@ -149,7 +152,16 @@
end
def log(msg)
env['captivity.logger'].debug(msg) if env['captivity.logger']
end
+
+ def print_compilation_error(e)
+ # Print the error to $stderr for good measure
+ $stderr.puts "Error when building asset #{request.url.inspect}: #{e.class}: #{e.message}"
+ e.backtrace.each do | line |
+ $stderr.puts "\t#{line}"
+ end
+ end
+
end