Skip to content
This repository has been archived by the owner on Nov 19, 2017. It is now read-only.

Error handling in db/migrations/migrate.initDB #6

Open
slmyers opened this issue May 29, 2016 · 1 comment
Open

Error handling in db/migrations/migrate.initDB #6

slmyers opened this issue May 29, 2016 · 1 comment
Assignees

Comments

@slmyers
Copy link
Member

slmyers commented May 29, 2016

Errors do not seem to be properly caught in the promise chain. Investigate.

function initDB(config) {
  const masterMapping   = mapper.generateMasterMapping(mapper.gatherScreenerMappings());
  testConnect(config.client)
  // master index and mappings
  .then(utils.initIndex(config.client, config.masterIndex))
  .then(utils.initMapping(config.client, config.masterIndex, config.masterTypeName, masterMapping))
  // response index and mappings
  .then(utils.initIndex(config.client, config.responseIndex))
  .then(utils.initMapping(config.client, config.responseIndex, config.responseTypeName, responseMapping))
  .then(initPercolators(config.client, config.masterIndex))
  .catch( e => {
    console.log(`exiting with ${e}`);
    process.exit(1);
  })
}
@slmyers slmyers self-assigned this May 29, 2016
@slmyers
Copy link
Member Author

slmyers commented May 29, 2016

Problem may lie in the utils package and how these functions are returned:

function mappingExists(elasticClient, indexName, typeName) {
  return elasticClient.indices.existsType({
    index: indexName,
    type: typeName
  });
}

This only returns a promise, but perhaps it should be thened and resolved or rejected.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant