I am writing CoffeeScript code for an API, and in the catching section of my code I have posted an IF statement. Now, during the compilation process, CoffeeScript says the IF statement was unexpected.
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
Mistake
/home/techno/node/snaprss/application.coffee:22:5: error: unexpected if
if err instanceOf NotFound
^^
Does anyone have any ideas where the problem is in my code?
source
share