refactor for catching I/O errors in one place. In case of internet connection lost in order to reconnect from external context