private static Exception TranslateException()

in Common/RetryHelper.cs [85:126]


        private static Exception TranslateException(Guid requestId, Exception e)
        {
            var ex = UnwrapIfAggregateException(e);
            if (ex is VssServiceException)
            {
                //Retry in following cases only
                //VS402335: QueryTimeoutException
                //VS402490: QueryTooManyConcurrentUsers
                //VS402491: QueryServerBusy
                //TF400733: The request has been canceled: Request was blocked due to exceeding usage of resource 'WorkItemTrackingResource' in namespace 'User.'
                if (ex.Message.Contains("VS402335")
                    || ex.Message.Contains("VS402490")
                    || ex.Message.Contains("VS402491")
                    || ex.Message.Contains("TF400733"))
                {
                    Logger.LogWarning(LogDestination.File, ex, $"VssServiceException exception caught for {requestId}:");
                }
                else
                {
                    //Specific TF or VS errors. No need to retry DO NOT THROW
                    return new RetryPermanentException($"Permanent error for {requestId}, not retrying", ex);
                }
            }
            else if (ex is HttpRequestException)
            {
                // all request exceptions should be considered retryable
                Logger.LogWarning(LogDestination.File, ex, $"HttpRequestException exception caught for {requestId}:");
            }
            // TF237082: The file you are trying to upload exceeds the supported file upload size
            else if (ex.Message.Contains("TF237082"))
            {
                return new RetryPermanentException($"Permanent error for {requestId}, not retrying", ex);
            }
            else
            {
                //Log and throw every other exception for now - example HttpServiceException for connection errors
                //Need to retry - in case of connection timeouts or server unreachable etc.
                Logger.LogWarning(LogDestination.File, ex, $"Exception caught for {requestId}:");
            }

            return ex;
        }