Skip to content

Commit

Permalink
I was getting an error:
Browse files Browse the repository at this point in the history
TypeError: Invalid type `undefined`
    at Function.interpretAsType (/home/sjuul/node_modules/mongoose/lib/schema.js:223:8)
    at Schema.path (/home/sjuul/node_modules/mongoose/lib/schema.js:182:29)
    at Schema.add (/home/sjuul/node_modules/mongoose/lib/schema.js:118:12)
    at new Schema (/home/sjuul/node_modules/mongoose/lib/schema.js:39:10)
    at Object.<anonymous> (/home/sjuul/jsServer/schemas.js:10:23)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Module.require (module.js:357:17)

I wanted it to warn me where it came from.
I'm still getting the error but at least this fixes the part where people wont know where it came from.
  • Loading branch information
obeleh authored and aheckmann committed Feb 2, 2012
1 parent 2740ffa commit cc20d1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -219,6 +218,10 @@ Schema.interpretAsType = function (path, obj) {

return new Types.Array(path, cast || Types.Mixed, obj);
}

if (Types[type.name] == undefined){
throw new TypeError('Undefined type at `' + path + '`');
}
return new Types[type.name](path, obj);
};

Expand Down

0 comments on commit cc20d1c

Please sign in to comment.