Fixed error handling for resource retrieval