private void HandleDownloadAndSaveObjectError(long requestId, RetryWrapper <GitObjectsHttpRequestor.GitObjectTaskResult> .ErrorEventArgs errorArgs) { // Silence logging 404's for object downloads. They are far more likely to be git checking for the // previous existence of a new object than a truly missing object. GitObjectsHttpException ex = errorArgs.Error as GitObjectsHttpException; if (ex != null && ex.StatusCode == HttpStatusCode.NotFound) { return; } RetryWrapper <GitObjectsHttpRequestor.GitObjectTaskResult> .StandardErrorHandler(this.Tracer, requestId, nameof(this.TryDownloadLooseObject))(errorArgs); }
private void HandleDownloadAndSaveObjectError(bool retryOnFailure, long requestId, RetryWrapper <GitObjectsHttpRequestor.GitObjectTaskResult> .ErrorEventArgs errorArgs) { // Silence logging 404's for object downloads. They are far more likely to be git checking for the // previous existence of a new object than a truly missing object. GitObjectsHttpException ex = errorArgs.Error as GitObjectsHttpException; if (ex != null && ex.StatusCode == HttpStatusCode.NotFound) { return; } // If the caller has requested that we not retry on failure, caller must handle logging errors bool forceLogAsWarning = !retryOnFailure; RetryWrapper <GitObjectsHttpRequestor.GitObjectTaskResult> .StandardErrorHandler(this.Tracer, requestId, nameof(this.TryDownloadLooseObject), forceLogAsWarning)(errorArgs); }
public bool TryQueryGVFSConfig(bool logErrors, out ServerGVFSConfig serverGVFSConfig, out HttpStatusCode?httpStatus) { serverGVFSConfig = null; httpStatus = null; Uri gvfsConfigEndpoint; string gvfsConfigEndpointString = this.repoUrl + GVFSConstants.Endpoints.GVFSConfig; try { gvfsConfigEndpoint = new Uri(gvfsConfigEndpointString); } catch (UriFormatException e) { EventMetadata metadata = new EventMetadata(); metadata.Add("Method", nameof(this.TryQueryGVFSConfig)); metadata.Add("Exception", e.ToString()); metadata.Add("Url", gvfsConfigEndpointString); this.Tracer.RelatedError(metadata, "UriFormatException when constructing Uri", Keywords.Network); return(false); } long requestId = HttpRequestor.GetNewRequestId(); RetryWrapper <ServerGVFSConfig> retrier = new RetryWrapper <ServerGVFSConfig>(this.RetryConfig.MaxAttempts, CancellationToken.None); if (logErrors) { retrier.OnFailure += RetryWrapper <ServerGVFSConfig> .StandardErrorHandler(this.Tracer, requestId, "QueryGvfsConfig"); } RetryWrapper <ServerGVFSConfig> .InvocationResult output = retrier.Invoke( tryCount => { using (GitEndPointResponseData response = this.SendRequest( requestId, gvfsConfigEndpoint, HttpMethod.Get, requestContent: null, cancellationToken: CancellationToken.None)) { if (response.HasErrors) { return(new RetryWrapper <ServerGVFSConfig> .CallbackResult(response.Error, response.ShouldRetry)); } try { string configString = response.RetryableReadToEnd(); ServerGVFSConfig config = JsonConvert.DeserializeObject <ServerGVFSConfig>(configString); return(new RetryWrapper <ServerGVFSConfig> .CallbackResult(config)); } catch (JsonReaderException e) { return(new RetryWrapper <ServerGVFSConfig> .CallbackResult(e, shouldRetry: false)); } } }); if (output.Succeeded) { serverGVFSConfig = output.Result; httpStatus = HttpStatusCode.OK; return(true); } GitObjectsHttpException httpException = output.Error as GitObjectsHttpException; if (httpException != null) { httpStatus = httpException.StatusCode; } return(false); }