private void LogError(IRestRequest request, IRestResponse response) { string parameters = ParseParameters(request); //Set up the information message with the URL, the status code, and the parameters. string info = $@" Request to {_client.BaseUrl.AbsoluteUri}{request.Resource} failed with status code {response.StatusCode}, parameters: {parameters}, and content: {response.Content}, Timeout is set to {request.Timeout}ms."; //Acquire the actual exception Exception ex; if (response != null && response.ErrorException != null) { ex = response.ErrorException; } else { ex = new Exception(info); info = string.Empty; } //Log the exception and info message _logging.LogErrorException(info, ex); }