/// <summary> /// Демаршалинг ошибки /// </summary> /// <param name="context"></param> /// <returns></returns> public static YandexMqServiceException ErrorUnmarshall(IResponseContext context) { try { var rootNode = GetXmlElement(context.ContentStream); var errorNode = rootNode.SelectSingleNode("Error"); var requestIdNode = rootNode.SelectSingleNode("RequestId"); var errorType = errorNode.SelectSingleNode("Type")?.InnerText ?? string.Empty; var errorCode = errorNode.SelectSingleNode("Code")?.InnerText ?? string.Empty; var errorMessage = errorNode.SelectSingleNode("Message")?.InnerText ?? string.Empty; var requestId = requestIdNode.InnerText; return(new YandexMqServiceException(errorMessage, errorType, errorCode, requestId, context.StatusCode)); } catch (Exception ex) { var message = new StreamReader(context.ContentStream).ReadToEnd(); YandexMqServiceException exception = new YandexMqServiceException(message, ex) { StatusCode = context.StatusCode }; return(exception); } }
/// <summary> /// Демаршалинг ошибки /// </summary> /// <param name="message"></param> /// <param name="innerException"></param> /// <param name="httpStatusCode"></param> /// <returns></returns> public static YandexMqServiceException ErrorUnmarshall(string message, Exception innerException, HttpStatusCode httpStatusCode) { YandexMqServiceException exception = new YandexMqServiceException(message, innerException) { StatusCode = httpStatusCode }; return(exception); }