Mongoose emits a stack trace for a cast error. I know how to prevent the Mongoose error - please do not answer how to prevent the error.
How can I stop Mongoose emitting stack trace errors in production?
Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters at new ObjectID (c:\proj\fboapp\node_modules\mongoose\node_modules\bson\lib\bson\objectid.js:38:11) at c:\proj\fboapp\routes\user\no_auth_user_api_routes.js:135:27 at Layer.handle [as handle_request] (c:\proj\fboapp\node_modules\express\lib\router\layer.js:95:5) at next (c:\proj\fboapp\node_modules\express\lib\router\route.js:131:13) at Route.dispatch (c:\proj\fboapp\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (c:\proj\fboapp\node_modules\express\lib\router\layer.js:95:5) at c:\proj\fboapp\node_modules\express\lib\router\index.js:277:22 at Function.process_params (c:\proj\fboapp\node_modules\express\lib\router\index.js:330:12) at next (c:\proj\fboapp\node_modules\express\lib\router\index.js:271:10) at Function.handle (c:\proj\fboapp\node_modules\express\lib\router\index.js:176:3) at router (c:\proj\fboapp\node_modules\express\lib\router\index.js:46:12) at Layer.handle [as handle_request] (c:\proj\fboapp\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (c:\proj\fboapp\node_modules\express\lib\router\index.js:312:13) at c:\proj\fboapp\node_modules\express\lib\router\index.js:280:7 at Function.process_params (c:\proj\fboapp\node_modules\express\lib\router\index.js:330:12) at next (c:\proj\fboapp\node_modules\express\lib\router\index.js:271:10)
Nodejs v0.12.3 Mongoose v4.4.3
throw
statement in mongoose. So, there are no way to "hide" it, except usingtry ... catch
as I know. – loadaverage