Skip to content

Commit

Permalink
fix: terminate process if config loading generates an error
Browse files Browse the repository at this point in the history
Closes: #58

BREAKING CHANGE:

Before this change, the config would be silently skipped.
Now an Error is thrown and its stack trace printed.
  • Loading branch information
targos committed Mar 1, 2017
1 parent bd5157b commit 1b36055
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/config/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const fs = require('fs');
const hasOwn = require('has-own');
const path = require('path');

const debug = require('../util/debug')('config:db');
const die = require('../util/die');

const dbConfig = module.exports = {};
Expand Down Expand Up @@ -34,7 +33,9 @@ if (homeDir) {
}
databaseConfig.designDocNames = designDocNames;
} catch (e) {
// database config is not mandatory
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
}
if (!databaseConfig.import) {
databaseConfig.import = {};
Expand All @@ -47,8 +48,8 @@ if (homeDir) {
}
}
} catch (e) {
debug.error(e);
die(`could not read databases from ${homeDir}`);
console.error(e.stack || e); // eslint-disable-line no-console
die(`could not read database configurations from ${homeDir}`);
}
}

Expand All @@ -63,9 +64,7 @@ function readImportConfig(databasePath, databaseConfig) {
importConfig = require(path.join(importPath, 'import'));
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
debug.trace(e.stack || e);
} else {
debug.warn(e);
throw e;
}
continue;
}
Expand Down

0 comments on commit 1b36055

Please sign in to comment.