Example #1
0
        private static string ExecuteWebRequest(WebRequest webRequest)
        {
            try
            {
                using (var response = webRequest.GetResponse())
                {
                    return ReadStream(response.GetResponseStream());
                }
            }
            catch (WebException webException)
            {
                if (webException.Response != null)
                {
                    var statusCode = ((HttpWebResponse)webException.Response).StatusCode;

                    var romitError = new RomitError();

                    if (webRequest.RequestUri.ToString().Contains("oauth"))
                        romitError = Mapper<RomitError>.MapFromJson(ReadStream(webException.Response.GetResponseStream()));
                    else
                        romitError = Mapper<RomitError>.MapFromJson(ReadStream(webException.Response.GetResponseStream()), "error");

                    throw new RomitException(statusCode, romitError, romitError.Message);
                }

                throw;
            }
        }
Example #2
0
        private static string ExecuteWebRequest(WebRequest webRequest)
        {
            try
            {
                using (var response = webRequest.GetResponse())
                {
                    return(ReadStream(response.GetResponseStream()));
                }
            }
            catch (WebException webException)
            {
                if (webException.Response != null)
                {
                    var statusCode = ((HttpWebResponse)webException.Response).StatusCode;

                    var romitError = new RomitError();

                    if (webRequest.RequestUri.ToString().Contains("oauth"))
                    {
                        romitError = Mapper <RomitError> .MapFromJson(ReadStream(webException.Response.GetResponseStream()));
                    }
                    else
                    {
                        romitError = Mapper <RomitError> .MapFromJson(ReadStream(webException.Response.GetResponseStream()), "error");
                    }

                    throw new RomitException(statusCode, romitError, romitError.Message);
                }

                throw;
            }
        }
 public RomitException(HttpStatusCode httpStatusCode, RomitError romitError, string message) : base(message)
 {
     HttpStatusCode = httpStatusCode;
     RomitError     = romitError;
 }
 public RomitException(HttpStatusCode httpStatusCode, RomitError romitError, string message) : base(message)
 {
     HttpStatusCode = httpStatusCode;
     RomitError = romitError;
 }