read write error handling