afloyd/mongo-migrate — pull request #14 by emirose (2014-04-11 03:30:05+00:00)
Title: don't try to use db connection if error is thrown

if there are issues connecting to mongo, db.migrationCollection is still called. When db.getConnection fails to get a connection, db is undefined and this exception is raised:

~/mongo-migrate/index.js:247
var migrationCollection = db.migrationCollection,
^
TypeError: Cannot read property 'migrationCollection' of undefined

Moving error conditional up, so that an error is logged instead.