Reduce code duplication.
Read all data before returning error.