sstephenson / eco

Embedded CoffeeScript templates
MIT License
1.71k stars 70 forks source link

Error messages report meaningless line numbers #14

Open aseemk opened 13 years ago

aseemk commented 13 years ago

Here's a simple example of an input string that fails:

https://gist.github.com/966185#file_error.html

But the error I get from it is this:

Error: Parse error on line 10: Unexpected 'IDENTIFIER'
    at Object.parseError (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/parser.js:470:11)
    at Object.parse (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/parser.js:540:22)
    at Object.compile (/usr/local/lib/node/.npm/coffee-script/1.0.1/package/lib/coffee-script.js:26:22)
    at /usr/local/lib/node/.npm/eco/1.0.3/package/lib/eco/compiler.js:11:27
    at Object.render (/usr/local/lib/node/.npm/eco/1.0.3/package/lib/eco/compiler.js:19:39)
    at Object.<anonymous> (/Users/aseemk/Projects/Node/misc/app.coffee:10:33)
    at ServerResponse._render (/usr/local/lib/node/.npm/express/2.2.2/package/lib/view.js:377:21)
    at ServerResponse.render (/usr/local/lib/node/.npm/express/2.2.2/package/lib/view.js:242:17)
    at Object.<anonymous> (/Users/aseemk/Projects/Node/misc/app.coffee:19:18)
    at param (/usr/local/lib/node/.npm/connect/1.3.0/package/lib/middleware/router.js:148:21)

But line 10 in the input is an empty line! After some investigating, line 10 is referring to the intermediate CoffeeScript that Eco generates:

https://gist.github.com/966185#file_generated.coffee

The problem is, that generated CoffeeScript isn't saved to a file or anything -- I had to manually add some console.logs() to Eco's compiler.js to see it.

The end result is that the line numbers reported in these error messages are pretty meaningless when you're looking at the source. It would be nice if they mapped to the source Eco template instead.

And for inspiration, the real goal to strive towards is the awesome reporting that Stylus has achieved:

http://tjholowaychuk.com/post/5002088731/stylus-vs-sass-vs-less-error-reporting

=)