LearnBoost/mongoose — Issue #750: schema/objectid.js giving undefined e.type
Author: awnist
Created: 2012-02-27 20:31:35+00:00
State: open

in schema/array.js:

try {
for (var i = 0, l = value.length; i < l; i++) {
value[i] = this.caster.cast(value[i], doc, init);
}
} catch (e) {
// rethrow
console.log(e);
throw new CastError(e.type, value);
}

e.type will be undefined when calling objectid.cast() from schema/objectid.js:

if (value.toString)
return oid.fromString(value.toString());

yielding:

stack: [Getter/Setter],
message: 'Cast to undefined failed for value "test"',
name: 'CastError',
type: undefined,