protected override bool ShouldRetry()

in tools/code/common/Http.cs [391:414]


    protected override bool ShouldRetry(HttpMessage message, Exception? exception) =>
        base.ShouldRetry(message, exception) || ShouldRetryInner(message, exception);

    protected override async ValueTask<bool> ShouldRetryAsync(HttpMessage message, Exception? exception) =>
        await base.ShouldRetryAsync(message, exception) || ShouldRetryInner(message, exception);

    private static bool ShouldRetryInner(HttpMessage message, Exception? exception)
    {
        try
        {
            return
                (message, exception) switch
                {
                    ({ Response.Status: 422 or 409 }, _) when HasManagementApiRequestFailedError(message.Response) => true,
                    ({ Response.Status: 412 }, _) => true,
                    ({ Response.Status: 429 }, _) => true,
                    _ => false
                };
        }
        catch (InvalidOperationException)
        {
            return false;
        }
    }