lgierth / promise.rb

Promises/A+ for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to set unhandled_rejection callback

sheerun opened this issue · comments

Hey!

Your library is awesome, but the promises in my code get often rejected and I don't even know about it.. Could you provide Promise.unhandled_rejection function to handle unhandled rejections (I'd use it in development only)

How would you define an unhandled rejection? Since a promise could be rejected before any callbacks are added to it, then it seems like we can only be sure that a promise is unhandled once it is being garbage collected (i.e. using ObjectSpace.define_finalizer).

Did you have any ideas of how this could be implemented? Could this be implemented in a class that derives from Promise to prototype the idea?