dart-lang/async_await — pull request #75 by kmillikin (2014-12-11 11:23:06+00:00)
Title: If E throws in await E, throw asynchronously.

The spec requires that if E throws in await E, the throw occurs
asynchronously. That is, even 'await throw exn' will allocate a
future that is completed with an error on the next turn of the event
loop. From 16.29 Await Expressions:

"""
Evaluation of an await expression a of the form await e proceeds as
follows: First, the expression e is evaluated. Next:

If e raises an exception x, then an instance f of class Future is
allocated and later completed with x.
"""

This is implemented by placing the translation of E in await E in the body
of a try block:

try {
[[E]].then(...);
} catch (ex, st) {
new Future.error(ex, st).catchError(ek.reify());
}

where ek is the current error continuation.