Better error handling in migration.js