Commit Graph

10 Commits

Author SHA1 Message Date
Demian Ferreiro 9e716b310d Avoid using a getter for the compiler error's "stack" property
Instead, set the "stack" property manually when the error gets updated on re-throws.
2013-08-02 01:52:36 -03:00
Demian Ferreiro 2b4a37296f Override the SyntaxError's "stack" property instead of deleting it
This makes the "stack" property more useful when it's shown on other Node.js applications that compile CoffeeScript (e.g. testing libraries) and should fix #3023. A minimal example:

    $ node -e 'require("coffee-script").compile("class class")'

    /usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:41
            throw err;
                  ^
    [stdin]:1:7: error: unexpected CLASS
    class class
          ^^^^^
2013-07-31 09:24:43 -03:00
Demian Ferreiro 3f9cdcf1fa Change how error messages are shown
Instead of throwing the syntax errors with their source file location and needing to then catch them and call a `prettyErrorMessage` function in order to get the formatted error message, now syntax errors know how to pretty-print themselves (their `toString` method gets overridden).

An intermediate `catch` & re-`throw` is needed at the level of `CoffeeScript.compile` and friends. But the benefit of this approach is that now libraries that use the `CoffeeScript` object directly don't need to bother catching the possible compilation errors and calling a special function in order to get the nice error messages; they can just print the error itself (or let it bubble up) and the error will know how to pretty-print itself.
2013-07-31 08:27:49 -03:00
Marc Häfner 13024e6911 Fix path separator issues in tests. 2013-06-22 14:57:23 +02:00
Alex Gorbatchev 3785996c44 Made stack patch test less brittle. 2013-06-13 13:50:05 -07:00
Alex Gorbatchev 3d761e73e3 Removed unnecessary source map generation during `require()` and made stack line number patching on by default. 2013-06-13 12:54:20 -07:00
Demian Ferreiro c0d1f22487 Add test for compiler errors on require()d files 2013-03-21 03:11:31 -03:00
Demian Ferreiro 5da7f6a488 Get rid of CompilationError and instead have a couple of functions on helpers.coffee 2013-03-05 01:13:46 -03:00
Demian Ferreiro fbc8417263 Fix failing parser error message test 2013-02-26 05:55:09 -03:00
Demian Ferreiro 44e3a76881 Add some error formatting tests
Thanks to them i discovered that the parser errors where indicating the wrong token ¬¬
2013-02-26 01:30:23 -03:00