Permalink
Browse files

more helpful error messages

  • Loading branch information...
1 parent 8d26267 commit d07713c71e32cf495d8ab472186b7dbedee41acf @caolan committed Apr 19, 2010
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/behaviors.js
View
10 lib/behaviors.js
@@ -28,7 +28,7 @@ exports.test = function(obj, behavior){
});
if(!match){
if(prop === undefined){
- throw new Error(k + ' is required');
+ throw new Error(k + ' is a required export');
}
else {
var expected_types = types.map(function(t){
@@ -56,6 +56,12 @@ exports.test = function(obj, behavior){
exports.require = function(modulename, behavior){
var m = require(modulename);
- exports.test(m, behavior);
+ try {
+ exports.test(m, behavior);
+ }
+ catch (e){
+ e.message = "The module '" + modulename + "' is invalid: " + e.message;
+ throw e;
+ }
return m;
};

0 comments on commit d07713c

Please sign in to comment.