Ejemplo n.º 1
0
        /// <summary>
        /// Gets the error response body.
        /// </summary>
        /// <param name="e">The web exception.</param>
        /// <returns></returns>
        public static string GetErrorResponseBody(WebException e)
        {
            WebResponse response = e.Response;
            string      contents = "";

            try {
                contents = MediaUtilities.GetStreamContentsAsString(
                    response.GetResponseStream());
            } catch {
                contents = e.Message;
            }
            return(contents);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the error response body.
        /// </summary>
        /// <param name="e">The web exception.</param>
        /// <returns></returns>
        public static string GetErrorResponseBody(WebException e)
        {
            WebResponse response = e.Response;
            string      contents = e.Message;

            try {
                if (response != null)
                {
                    contents = MediaUtilities.GetStreamContentsAsString(
                        response.GetResponseStream());
                }
            } catch {
                // Nothing much to do here, since this is an exception on top of an
                // exception (e.g. IOException on top of a WebException that was a
                // timeout), and it is enough to return the original WebException.
            }
            return(contents);
        }