private void HandleTransportException()

in src/Elastic.Transport/DistributedTransport.cs [336:356]


	private void HandleTransportException(BoundConfiguration boundConfiguration, Exception clientException, TransportResponse response)
	{
		if (response.ApiCallDetails is ApiCallDetails a)
		{
			//if original exception was not explicitly set during the pipeline
			//set it to the TransportException we created for the bad response
			if (clientException != null && a.OriginalException == null)
				a.OriginalException = clientException;
			//On .NET Core the TransportClient implementation throws exceptions on bad responses
			//This causes it to behave differently to .NET FULL. We already wrapped the WebException
			//under TransportException, and it exposes way more information as part of its
			//exception message e.g. the root cause of the server error body.
#if NETFRAMEWORK
			if (a.OriginalException is WebException)
				a.OriginalException = clientException;
#endif
		}

		Configuration.OnRequestCompleted?.Invoke(response.ApiCallDetails);
		if (boundConfiguration != null && clientException != null && boundConfiguration.ThrowExceptions) throw clientException;
	}