Wrap writeFailure so that the failure is returned