public CompletedEventArgs(Exception error, RequestFailure requestFailure = null) : this() { this.Error = error; this.RequestFailure = requestFailure; }
private RequestFailure CreateFailure(string reason, Exception error = null) { var fail = new RequestFailure { Reason = reason, Error = error, Timeout = this.Timeout, Url = this.Url }; var webEx = error as WebException; Uri uri; var validUri = Uri.TryCreate(fail.Url, UriKind.RelativeOrAbsolute, out uri); if (null != webEx) { fail.StatusText = webEx.Status.ToString(); var resp = webEx.Response as HttpWebResponse; if (null != resp) { fail.StatusCodeText = resp.StatusCode.ToString(); if (resp.StatusCode == HttpStatusCode.NotFound) { fail.NotFound = true; fail.IsCommon = true; if (validUri) { fail.FriendlyMessage = string.Format( "Received a Not Found response from host {0}. Verify your connectivity and host availability and try again later.", uri.Host); } } } } else { if (reason == TimeoutReason) { fail.IsCommon = true; if (validUri) { fail.FriendlyMessage = string.Format( "Timeout waiting for host {0}. Verify your connectivity and host availability and try again later. Timeout is '{1}'", uri.Host, this.Timeout); } } } return fail; }
private static void InvokeOnFailure(Action<RequestFailure> onFailure, RequestFailure failure) { DispatchUtil.SafeDispatch(() => onFailure(failure)); }
private void LocalAfterRequestFailure(RequestFailure failure) { LogInstance.LogInfo("Call complete with failure to {0} in {1}", this.Url, CallTimer.Stop()); AfterRequestFailure(failure); }
protected virtual void AfterRequestFailure(RequestFailure failure) { var ex = new Exception(string.Format("Request failed with reason '{0}'; see inner exception", failure.Reason), failure.Error); LogInstance.LogError("{0}: Service call failure. Reason: {1}, Error: {2}", this.GetType().Name, failure.Reason, failure.Error); OnAfterCompleted(new CompletedEventArgs(ex, failure)); }
protected override void AfterRequestFailure(RequestFailure failure) { // if we have something in cache, load that, even if expired; better than no data at all if (_cacheInfo.State != CacheStates.NotFound) { LoadFromCache(expiredOkay:true); } // let base log error, raise completed base.AfterRequestFailure(failure); }