Added error handling to resource fetching.