From 5f00d6478a1a6c07501e5f36cc581fbd992f7b93 Mon Sep 17 00:00:00 2001 From: Demian Ferreiro Date: Mon, 25 Feb 2013 19:20:37 -0300 Subject: [PATCH] Remove redundant filename in error message --- lib/coffee-script/coffee-script.js | 17 +++++------------ src/coffee-script.coffee | 13 +++++-------- 2 files changed, 10 insertions(+), 20 deletions(-) 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) ->