internal void SetError(WebException ex) { if (ex == null) { Error = null; return; } try { string ErrorMsg; string ErrorCode; if (ex.Response.ResponseUri.ToString().Contains("/v1.2") ) { ErrorMsg = "error"; ErrorCode = "errorcode"; } else { ErrorMsg = "error_msg"; ErrorCode = "error_code"; } var s = new StreamReader(ex.Response.GetResponseStream()); var response = s.ReadToEnd(); XDocument doc = XDocument.Parse(response); var error = doc.Root.Descendants(ErrorMsg).First().Value; List<string> errorCodes = new List<string>(); foreach (var errorCode in doc.Root.Descendants(ErrorCode)) { errorCodes.Add(errorCode.Value); } Error = new DoxError(ex, error, errorCodes.ToArray()); } catch (Exception) { Error = new DoxError(ex, ex.Message); } }
internal void SetError(string message) { Error = (message == null) ? null : new DoxError(null, message); }
internal void SetError(Exception ex, string message = null) { string errorMessage = message ?? ex.Message; Error = (ex == null) ? null : new DoxError(ex, errorMessage); }
internal void ClearError() { Error = null; }