handle reading error from input stream