Skip to content

ReferenceError always displays line 0 in stacktrace  #2

@alonbardavid

Description

@alonbardavid

It appears that when coffee-script compile the file correctly, but results in a javascript file that has a ReferenceError (I.E. it fails inside the require(module)), the resulting sourcemap will not properly map the location of the error, and results in a stack trace frame with 0:0.

Test case:

badJsSyntax.coffee

exports.innerErr = () ->
    throw new Error("Inside Inner Err");
exports.outerErr = () ->
    exports.innerErr()
zzz
exports.nestedErr = () ->
    anotherErr.throwErr()

testCase:

it("should show proper coffee stack when we have syntax error in JS but not coffeescript", function() {
            try {
                require("./badJsSyntax")
            } catch (err) {
                var lines = err.stack.split("\n")
                expect(err.message).to.match(/zzz is not defined/)
                expect(lines[1]).to.match(/badJsSyntax.coffee:5:1\)$/)
                expect(lines[1]).to.match(/badJsSyntax.coffee:16:4\)$/)
            }
        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions