Search code examples
javascriptcoffeescript

CoffeeScript compiling: Unexpected IF


I am writing some CoffeeScript code for an API, and in the error catching section of my code I placed an IF statement. Now, during the compilation process CoffeeScript is saying that the IF statement was unexpected.

#  Handle Errors
app.error (err, req, res, next) ->
    if err instanceof NotFound
        res.send '404, not found.'
    else
        res.send '500, internal server error.'

app.get '/*', (req, res) ->
    throw new NotFound

NotFound = (msg) ->
    this.name = 'NotFound'
    Error.call this, msg
    Error.captureStackTrace this, arguments.callee

The error is

/home/techno/node/snaprss/application.coffee:22:5: error: unexpected if
    if err instanceOf NotFound
    ^^

Does anyone have any ideas where the issue is within my code?


Solution

  • Unexpected 'INDENT' in CoffeeScript Example Code

    This issue looks somehow similar.

    Consider therefore checking tabs and spaces in your editor.