improve error handling of protected branches API call
Please describe the problem you think should be solved
@niik raised an excellent point at the end of #7826
My only remaining concern now is with how we're dealing with failed API requests. Consumers of the
fetchProtectedBranchesmethod have no way of differentiating between an API request that returned zero protected branches and one that failed meaning that if we attempt to refresh the list of protected branches while there's no internet connectivity we'll immediately clear the internal list of protected branches. Given that this is a pre-existing behavior I don't think it should hold up this PR but I feel like it warrants further investigation to determine if that's the behavior we want.
[Optional] Do you have any potential solutions in mind?
We should preserve the list of cached protected branches if the API call fails due to an intermittent network issue. But I think we need to be mindful of other cases here (e.g. 404) and ensure the app handles them correctly.