111,093
社区成员




catch (WebException ex)
{
string errorMessage = ex.Message;
//需判断response是否==null
WebResponse exResponse = ex.Response;
if (exResponse == null)
{
throw;
}
else
{
receiveStreamOut = exResponse.GetResponseStream();
srOut = new StreamReader(receiveStreamOut, encoding.IsNullOrEmpty() ? Encoding.UTF8 : Encoding.GetEncoding(encoding));
string result = srOut.ReadToEnd();
exResponse.Close();
//此处将错误信息和json信息同时返回
throw new CustomWebException(result, url, ex);
}
}