How can you implement error handling for Mongoose (current version v5.1.5)?
For example, let's assume the following code where a user detail is being looked up.
let u = await user.find({ code: id }).lean();
return u;
And some error occurs, how should it be handled?
Secondly, can we have centralised error handling function which will get triggered whenever an error happens in any of the Mongoose code, it gets directed to a particular function in the project where it can be handled.