private async static Task <SdrcFlurHttpResponse <T> > SdrcHttpCallAsync <T>(string request, Func <Task <T> > httpCallAsync) { var sdrcResponse = new SdrcFlurHttpResponse <T>(); try { sdrcResponse.Request = request; sdrcResponse.Data = await httpCallAsync().ConfigureAwait(false); sdrcResponse.StatusCode = HttpStatusCode.OK; } catch (FlurlHttpTimeoutException ex) { sdrcResponse.StatusCode = (HttpStatusCode)SdrcHttpStatusCode.FlurlTimeOut; sdrcResponse.Exception = ex; } catch (FlurlHttpException ex1) { if (ex1.InnerException is TaskCanceledException) { sdrcResponse.StatusCode = ex1.Call.Response?.StatusCode ?? (HttpStatusCode)(SdrcHttpStatusCode.FlurlTaskCanceled); } else { sdrcResponse.StatusCode = ex1.Call.Response?.StatusCode ?? (HttpStatusCode)(SdrcHttpStatusCode.FlurlException); } if (ex1.Call?.Response?.Content != null) { try { sdrcResponse.Message = await ex1.Call.Response.Content.ReadAsStringAsync().ConfigureAwait(false); } catch // (Exception ex11) { // sdrcResponse.Message = ex11.Message; } } sdrcResponse.Exception = ex1; } catch (Exception ex3) { sdrcResponse.StatusCode = (HttpStatusCode)(SdrcHttpStatusCode.Exception); sdrcResponse.Exception = ex3; } return(sdrcResponse.MarkReceived()); }
public static bool HasException(this SdrcFlurHttpResponse thisValue) => thisValue.Exception != null;
public static bool IsHttpStatusCodeException(this SdrcFlurHttpResponse thisValue) => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)SdrcHttpStatusCode.Exception);
public static bool IsHttpStatusCodeFlurlTaskCanceled(this SdrcFlurHttpResponse thisValue) => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)SdrcHttpStatusCode.FlurlTaskCanceled);
public static bool IsHttpStatusCodeFlurlTimeout(this SdrcFlurHttpResponse thisValue) => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)SdrcHttpStatusCode.FlurlTimeOut);
public static bool IsHttpStatusCodeUndefined(this SdrcFlurHttpResponse thisValue) => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)SdrcHttpStatusCode.Undefined);
public static bool IsHttpStatusCodeOK(this SdrcFlurHttpResponse thisValue) => thisValue.StatusCode.IsHttpStatusCode(HttpStatusCode.OK);