handle situation where the read is interrupted and return an error