I have a method that seems to be throwing a "System.Excpetion 0: " without any message. This exception is happening in the production code as seen from the logs but I can't replicate it so far in my local environment. Looks like it comes from RestSharp RestClient(string url) where I've tried an invalid url and a correct url but nothing has replicated such exception yet.
endpoint.url is just a string to hold the base url endpoint.endpoint is remaining part of the url for the get endpoint i want to hit endpoint.basicAuth
stack trace says it comes from line 238:
238: var client = new RestClient(endpoint.url);
var request = new RestRequest(endpoint.endpoint, Method.GET);
request.AddHeader("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(": " + endpoint.basicAuthToken)));
var response = client.Execute(request);
if(response.StatusCode != HttpStatusCode.OK)
{
throw new Exception(message: response.StatusCode.ToString());
}
string contentString = response.Content.ToString();
A client.Execute(request) with a invalid url is getting {"The underlying connection was closed: The connection was closed unexpectedly."} therefore the IRestReponse returned has a StatusCode property of 0 and when catching this exception to print out its excpetion message 'throw new Exception(message: response.StatusCode.ToString());' it writes what I'm seeeig of "System.Exception: 0"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.