Browse files

Throw an exception if config cannot be read. Fixes #47

  • Loading branch information...
1 parent e0fe7d5 commit 0adfe3384e2a7e7d5a0b3c3ad92c6646d38c8387 @laktek committed Dec 13, 2012
Showing with 7 additions and 8 deletions.
  1. +1 −3 lib/config_handler.js
  2. +4 −3 spec/config_handler.spec.js
  3. +2 −2 spec/utils/module_utils.spec.js
View
4 lib/config_handler.js
@@ -104,9 +104,7 @@ module.exports = {
if (alternate_config_paths.length) {
return readConfigCallback();
} else {
- console.log("Cannot read the custom config: " + err);
- console.log("Using the default config.");
- return callback(default_config);
+ throw("Failed to read the configurations.\nIf you have already created a config file, please check it for any syntax errors.");
}
} else {
var default_config_clone = deep_extend({}, default_config);
View
7 spec/config_handler.spec.js
@@ -243,9 +243,10 @@ describe("get config", function() {
return callback("error", null);
});
- config_handler.getConfig("custom_config.json", function(output) {
- expect(output.server.port).toEqual(9009);
- });
+ var spyCallback = jasmine.createSpy();
+ expect(function() {
+ config_handler.getConfig("custom_config.json", spyCallback);
+ }).toThrow();
});
View
4 spec/utils/module_utils.spec.js
@@ -31,7 +31,7 @@ describe("require and setup", function() {
if (path === "/current/node_modules/custom_module") {
return {}
} else {
- raise("module not found");
+ throw("module not found");
}
});
@@ -44,7 +44,7 @@ describe("require and setup", function() {
if (path === "custom_module") {
return {}
} else {
- raise("module not found");
+ throw("module not found");
}
});

0 comments on commit 0adfe33

Please sign in to comment.