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); } } } }
public YandexLinguisticsException(YandexError error) : base(error.Message) { Code = error.Code; }