Exemplo n.º 1
0
        private void CheckErrors(IRestResponse response)
        {
            int iStatusCode = (int)response.StatusCode;

            if (!HttpIsOK(iStatusCode))
            {
                if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    throw new RecurlyNotFoundException();
                }
                else
                {
                }
                if ((int)response.StatusCode == HTTP_UNPROCESSABLE_ENTITY)
                {
                    RecurlyValidationErrorCollection errors = null;
                    try
                    {
                        errors = mSerializer.Deserialize <RecurlyValidationErrorCollection>(response);
                    }
                    catch (YAXException)
                    {
                        RecurlyError error = null;
                        try
                        {
                            error = mSerializer.Deserialize <RecurlyError>(response);
                        }
                        catch (YAXException)
                        {
                            RecurlyTransactionErrors transactionErrors = null;
                            try
                            {
                                transactionErrors = mSerializer.Deserialize <RecurlyTransactionErrors>(response);
                            }
                            catch (YAXException)
                            {
                                throw new RecurlyException(response.Content);
                            }
                            throw new RecurlyTransactionException(transactionErrors);
                        }
                        throw new RecurlyErrorException(error);
                    }
                    throw new RecurlyValidationException(errors);
                }
            }
        }
 public RecurlyValidationException(RecurlyValidationErrorCollection errors)
     : base()
 {
     this.Errors = errors;
 }