Exemple #1
0
        public static void Apply(this IWriteableExceptionResponseMetadata exception, HttpResponseMessage response)
        {
            if (response == null)
            {
                return;
            }

            try
            {
                exception.StatusCode            = response.StatusCode;
                exception.ReasonPhrase          = response.ReasonPhrase;
                exception.ResponseContentType   = response.Content?.Headers?.ContentType?.MediaType;
                exception.ResponseContentLength = response.Content?.Headers?.ContentLength;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            } // don't let exception logging info cause exception
        }
Exemple #2
0
        public static void Apply(this IWriteableExceptionResponseMetadata exception, HttpRequestMessage request)
        {
            if (request == null)
            {
                return;
            }

            try
            {
                exception.RequestUri           = request.RequestUri;
                exception.RequestMethod        = request.Method;
                exception.ResponseContentType  = request.Headers?.Accept?.ToString() ?? request.Content?.Headers?.ContentType?.MediaType;
                exception.RequestContentLength = request.Content?.Headers?.ContentLength;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #3
0
 public static void Apply(this IWriteableExceptionResponseMetadata exception, HttpRequestMessage request,
                          HttpResponseMessage response)
 {
     exception.Apply(request);
     exception.Apply(response);
 }