Missing Catch or Finally After Try
express, javascript, node.js
Solution
The error was a missing bracket on an if statement in my EJS template. As that trace shows, it was in the exports.compile function (which is called by res.render()) that this error occurs) - the lib author uses a string to create a new function, which encloses my EJS file functionality in a try block, which becomes a dangling try because my missing opening bracket in my if block caused a syntax error in the new anonymous function created as a string and built with "new Function('str')".
@T.J.Crowder pointed out, that stack trace is perfectly clear, and did ultimately lead to this solution. I removed some of my example code because it definitely wasn't linked to the ultimate problem.
Problem
I'm using Node, Express with EJS view engine, nano (for couchdb), and I'm running into this pretty puzzling error which I cold not find any Node/JS specific info about via SO or Goog. The area of my code that seems to be triggering this involves nested async callbacks which grab a document from CouchDB, look through it for some matches, and push an object to an array in my private scope. And the error: ``` Express 500 SyntaxError: Missing catch or finally after try at Object.Function (unknown source) at exports.compile (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/ejs/lib/ejs.js:234:12) at Object.exports.render (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/ejs/lib/ejs.js:273:10) at View.exports.renderFile [as engine] (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/ejs/lib/ejs.js:303:22) at View.render (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/express/lib/view.js:75:8) at Function.app.render (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/express/lib/application.js:501:10) at ServerResponse.res.render (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/express/lib/response.js:719:7) at exports.dashboard.res.render.msg (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/routes/index.js:19:29) at module.exports.read (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/api/Character.js:56:25) at Request._callback (/Users/Keith/Desktop/netPoetica/1- Projects/dcc-chargen/node_modules/nano/nano.js:296:11) ```