in CredentialProvider.Microsoft/RequestHandlers/RequestHandlerBase.cs [50:97]
public async Task HandleResponseAsync(IConnection connection, Message message, IResponseHandler responseHandler, CancellationToken cancellationToken)
{
Stopwatch timer = new Stopwatch();
timer.Start();
Connection = connection;
TRequest request = MessageUtilities.DeserializePayload<TRequest>(message);
try {
TResponse response = null;
Logger.Verbose(string.Format(Resources.HandlingRequest, message.Type, message.Method, timer.ElapsedMilliseconds, message.Payload.ToString(Formatting.None)));
try {
using (GetProgressReporter(connection, message, cancellationToken))
{
response = await HandleRequestAsync(request).ConfigureAwait(continueOnCapturedContext: false);
}
}
catch (Exception ex) when (cancellationToken.IsCancellationRequested)
{
// NuGet will handle canceling event but verbose logs in this case might be interesting.
Logger.Verbose(string.Format(Resources.RequestHandlerCancelingExceptionMessage, ex.InnerException, ex.Message));
return;
}
Logger.Verbose(string.Format(Resources.SendingResponse, message.Type, message.Method, timer.ElapsedMilliseconds));
// If we did not send a cancel message, we must submit the response even if cancellationToken is canceled.
await responseHandler.SendResponseAsync(message, response, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
Logger.Verbose(string.Format(Resources.TimeElapsedAfterSendingResponse, message.Type, message.Method, timer.ElapsedMilliseconds));
}
catch (Exception ex)
{
// don't report cancellations to the console during shutdown, they're most likely not interesting.
bool cancelingDuringShutdown = ex is OperationCanceledException && Program.IsShuttingDown;
if (cancelingDuringShutdown)
{
Logger.Log(LogLevel.Verbose, allowOnConsole: false, Resources.WhileShuttingDown);
}
Logger.Log(LogLevel.Verbose, allowOnConsole: !cancelingDuringShutdown, string.Format(Resources.ResponseHandlerException, message.Method, message.RequestId));
Logger.Log(LogLevel.Verbose, allowOnConsole: !cancelingDuringShutdown, ex.ToString());
throw;
}
timer.Stop();
}