diff --git a/lib/coffee-script/coffee-script.js b/lib/coffee-script/coffee-script.js index cda53a54..3cd22229 100644 --- a/lib/coffee-script/coffee-script.js +++ b/lib/coffee-script/coffee-script.js @@ -44,19 +44,12 @@ options = {}; } merge = exports.helpers.merge; - try { - js = (parser.parse(lexer.tokenize(code, options))).compile(options); - if (!options.header) { - return js; - } - } catch (err) { - if (options.filename) { - err.message = "In " + options.filename + ", " + err.message; - } - throw err; + js = (parser.parse(lexer.tokenize(code, options))).compile(options); + if (options.header) { + header = "Generated by CoffeeScript " + this.VERSION; + js = "// " + header + "\n" + js; } - header = "Generated by CoffeeScript " + this.VERSION; - return "// " + header + "\n" + js; + return js; }; exports.tokens = function(code, options) { diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 8eb28e0a..827d0bce 100644 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -36,14 +36,11 @@ exports.helpers = require './helpers' # compiler. exports.compile = compile = (code, options = {}) -> {merge} = exports.helpers - try - js = (parser.parse lexer.tokenize(code, options)).compile options - return js unless options.header - catch err - err.message = "In #{options.filename}, #{err.message}" if options.filename - throw err - header = "Generated by CoffeeScript #{@VERSION}" - "// #{header}\n#{js}" + js = (parser.parse lexer.tokenize(code, options)).compile options + if options.header + header = "Generated by CoffeeScript #{@VERSION}" + js = "// #{header}\n#{js}" + js # Tokenize a string of CoffeeScript code, and return the array of tokens. exports.tokens = (code, options) ->