示例#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()}.");
 }