Exemple #1
0
        private void HandleErrors(HttpWebResponse webResponse, string response)
        {
            int     statusCode  = (int)webResponse.StatusCode;
            dynamic data        = null;
            string  errorCode   = string.Empty;
            string  field       = string.Empty;
            string  description = string.Empty;

            try
            {
                data      = JsonConvert.DeserializeObject(response);
                errorCode = data["error"]["code"];
                Enum.Parse(typeof(ErrorCodes), errorCode);
                description = data["error"]["description"];
                field       = data["error"]["field"];
            }
            catch (Exception)
            {
                ThrowServerError(statusCode);
            }

            throw ErrorCodeHelper.Get(description, errorCode, statusCode, field);
        }