Improved error catching for file retrieval