Add better error handling to network requests