Closed andyli closed 8 years ago
Which language? Languages with an event loop will defer the error handling for a future event. Otherwise you need to set up how the event loop is called and your own threading model.
I see.. I'm targeting Neko. Look like Promise is not very well-suited to targets without an event loop.
I'm writing a function that may perform an HTTP download, that may be sync/async depended on target. Here is the part that illustrate the sync logic:
The problem is that, when the error occurs, the Promise has not been returned to the call-site yet. It means the error handler has not yet been attached, thus the Promise will throw the error immediately.
Is there a workaround or am I using it wrongly?