コード例 #1
0
        private async static Task <EmcFlurHttpResponse <T> > EmcHttpCall <T>(Func <Task <T> > httpCallAsync)
        {
            var emcResponse = new EmcFlurHttpResponse <T>();

            try
            {
                emcResponse.Self = await httpCallAsync().ConfigureAwait(false);

                emcResponse.StatusCode = HttpStatusCode.OK;
            }
            catch (FlurlHttpTimeoutException ex)
            {
                emcResponse.StatusCode = (HttpStatusCode)EmcHttpStatusCode.FlurlTimeOut;
                emcResponse.Exception  = ex;
            }
            catch (FlurlHttpException ex1)
            {
                emcResponse.StatusCode      = ex1.Call.Response?.StatusCode ?? (HttpStatusCode)(EmcHttpStatusCode.FlurlException);
                emcResponse.ResponseMessage = await ex1.Call.Response.Content.ReadAsStringAsync().ConfigureAwait(false);

                emcResponse.Exception = ex1;
            }
            catch (Exception ex3)
            {
                emcResponse.StatusCode = (HttpStatusCode)(EmcHttpStatusCode.Exception);
                emcResponse.Exception  = ex3;
            }
            return(emcResponse);
        }
コード例 #2
0
 public static bool HasException(this EmcFlurHttpResponse thisValue)
 => thisValue.Exception != null;
コード例 #3
0
 public static bool IsHttpStatusCodeException(this EmcFlurHttpResponse thisValue)
 => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)EmcHttpStatusCode.Exception);
コード例 #4
0
 public static bool IsHttpStatusCodeRequestTimeout(this EmcFlurHttpResponse thisValue)
 => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)EmcHttpStatusCode.FlurlTimeOut);
コード例 #5
0
 public static bool IsHttpStatusCodeUndefined(this EmcFlurHttpResponse thisValue)
 => thisValue.StatusCode.IsHttpStatusCode((HttpStatusCode)EmcHttpStatusCode.Undefined);
コード例 #6
0
 public static bool IsHttpStatusCodeOK(this EmcFlurHttpResponse thisValue)
 => thisValue.StatusCode.IsHttpStatusCode(HttpStatusCode.OK);