コード例 #1
0
        /// <summary>
        /// Get error response as text
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static string GetErrorResponsePhrase(this HttpClientApiException exception)
        {
            if (exception.ErrorResponse == null)
            {
                return(string.Empty);
            }

            return($"Error response: {exception.ErrorResponse.ToJson()}.");
        }
コード例 #2
0
 /// <summary>
 /// Get exception description including all the details about error, as text
 /// </summary>
 /// <param name="exception"></param>
 /// <returns></returns>
 public static string GetDescription(this HttpClientApiException exception)
 {
     return($"Couldn't execute http request. {GetErrorResponsePhrase(exception)} {GetStatusCodePhrase(exception)}");
 }
コード例 #3
0
 /// <summary>
 /// Get status code as text
 /// </summary>
 /// <param name="exception"></param>
 /// <returns></returns>
 public static string GetStatusCodePhrase(this HttpClientApiException exception)
 {
     return($"Status code: {exception.HttpStatusCode.ToString()}.");
 }