How to surface custom CastError messages?

22 views
Skip to first unread message

Mark Stosberg

unread,
Apr 29, 2016, 11:49:05 AM4/29/16
to Mongoose Node.JS ODM
Hello,

I'm working on `mongoose-geojson-schema`, which adds validation for GeoJSON objects to Mongoose schemas. 

As part of this, we'd like set custom error messages for various validation failures. You can see our code here:


An example syntax we tried is:

    throw new mongoose.SchemaType.CastError('Crs must be an object or null');

Yet when we test the code and review the exceptions thrown, they are generic messages about "failure to cast".

How can the user find out the detailed error message? Is there something else that we need to in the plugin, or something else the user does on the calling side?

Thanks,

     Mark


Reply all
Reply to author
Forward
0 new messages