using System; using System.Collections.Generic; using System.Linq; using System.Text; using POSV.HttpApi; using POSV.Utils; namespace POSV.Proxy.Base { public class ProxyBase { public ProxyBase() { LOGGET = NLog.LogManager.GetLogger(GetType().FullName); } protected static NLog.Logger LOGGET = null; protected string PaserErrors(string response) { string result = string.Empty; try { LOGGET.Error(response); Dictionary _errorDesc = new Dictionary(); Errors mainError = JsonUtils.Deserialize(response); if (_errorDesc.ContainsKey(mainError.Code)) { result = _errorDesc[mainError.Code]; } else { result = mainError.Message; } List subError = mainError.SubErrors; if (subError != null && subError.Count > 0) { SubErrors error = subError[0]; if (_errorDesc.ContainsKey(error.Code)) { result = _errorDesc[error.Code]; } else { result = error.Message; } } } catch (Exception ex) { LOGGET.Error(ex, "非法的错误信息格式"); // result = _errorDesc["9999"]; } return result; } } }