mpromise
mpromise copied to clipboard
Provide unhandled rejection detection
Cross post of https://github.com/Automattic/mongoose/issues/2918
Hi, most promise libraries (Bluebird, When, Q, Native promises in io.js and so on) support unhandled rejection detection which greatly simplifies dealing with errors in promises. Other libraries (RSVP, native promises in node.js) plan to add this feature.
Here is the proposal as currently implemented in most major libraries.
It could be great if Mongoose promises supported these hooks - I'd love to help with implementation guidance if you'd like it.
Anyone?
@benjamingr require('mongoose/lib/promise').prototype.error = console.error; Will do the trick.
:+1: Ohh, wait, that's my job... On it. @benjamingr if you're still interested in helping the place to tigger the hooks is https://github.com/aheckmann/mpromise/blob/master/lib/promise.js#L108 Should add a few tests as well.