Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Omise.ApiException"/> class.
        /// </summary>
        /// <param name="webException">Web exception.</param>
        public ApiException(WebException webException)
            : base(defaultMessage, webException)
        {
            this.webException = webException;
            if (webException.Response != null)
            {
                using (var sr = new StreamReader(webException.Response.GetResponseStream(), true))
                {
                    var    errorResult = new StringBuilder();
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        errorResult.AppendLine(line);
                    }

                    apiErrorObject = new ApiErrorObject(errorResult.ToString());
                }
                StatusCode = ((HttpWebResponse)webException.Response).StatusCode;
            }
        }
Beispiel #2
0
 private ApiException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.apiErrorObject = info.GetValue("ApiErrorObject", typeof(ApiErrorObject)) as ApiErrorObject;
 }