Lately, I've been getting into promises vs regular callbacks.However, I've run into strange occurrences with errors with certain modules, such as mongodb and npm "request". Can anyone catch what I'm doing wrong? I'm still new with promises, so perhaps there's something I'm missing.For example, mongodb:return mongodb.MongoClient.connect(mongoSecretURI).then((err, db) => { if (err); return Promise.reject(err); var collection = db.collection('someNotFoundCollection'); console.log('collection == ' + collection); // Not found -- this will catch the err, but with the err of {} // If I used a "normal", non-promise callback, // this would return a useful stacktrace and what was wrong }) .catch((err) => { console.log(err); // err == {} (NOT [obj, obj], literally nothing - an empty obj) return Promise.reject(err); });
Submitted May 04, 2017 at 02:22PM by xblade724
No comments:
Post a Comment