Esempio n. 1
0
        protected T SendRequest <T>(RestRequest request)
        {
            RestResponse             response     = (RestResponse)_client.Execute(request);
            XmlAttributeDeserializer deserializer = new XmlAttributeDeserializer();

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var result = deserializer.Deserialize <T>(response);
                return(result);
            }
            else
            {
                YandexError error = null;
                try
                {
                    error = deserializer.Deserialize <YandexError>(response);
                }
                finally
                {
                    if (error == null)
                    {
                        var errorMessage = !string.IsNullOrEmpty(response.ErrorMessage) ?
                                           response.ErrorMessage : response.Content;
                        throw new YandexLinguisticsException((int)response.StatusCode, errorMessage);
                    }
                    else
                    {
                        throw new YandexLinguisticsException(error);
                    }
                }
            }
        }
Esempio n. 2
0
 public YandexLinguisticsException(YandexError error)
     : base(error.Message)
 {
     Code = error.Code;
 }
		public YandexLinguisticsException(YandexError error)
			: base(error.Message)
		{
			Code = error.Code;
		}