Distill out code out from WriteAsync.

Now that the callback has an exception as the first and only
argument, it can be used with Wrap.