Improved error handling for file transfer implementation.