Wrap exception to find out number of read bytes