Log instead of re-throwing less parser errors

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-04-16 12:10:07 -07:00
parent afa58160b3
commit a1cab1a692

View File

@@ -135,18 +135,28 @@ window.requireStylesheet = (path) ->
throw new Error("Could not find a file at path '#{path}'")
window.loadStylesheet = (path) ->
content = fsUtils.read(path)
if fsUtils.extension(path) == '.less'
parser = new less.Parser
syncImport: true
paths: config.lessSearchPaths
filename: path
loadLessStylesheet(path)
else
fsUtils.read(path)
parser.parse content, (e, tree) ->
throw new Error(e.message, path, e.line) if e
window.loadLessStylesheet = (path) ->
parser = new less.Parser
syncImport: true
paths: config.lessSearchPaths
filename: path
try
content = null
parser.parse fsUtils.read(path), (e, tree) ->
throw e if e?
content = tree.toCSS()
content
content
catch e
console.error """
Error compiling less stylesheet: #{path}
Line number: #{e.line}
#{e.message}
"""
window.removeStylesheet = (path) ->
unless fullPath = window.resolveStylesheet(path)