コード例 #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);
                    }
                }
            }
        }
コード例 #2
0
 public YandexLinguisticsException(YandexError error)
     : base(error.Message)
 {
     Code = error.Code;
 }
コード例 #3
0
		public YandexLinguisticsException(YandexError error)
			: base(error.Message)
		{
			Code = error.Code;
		}