@@ -161,6 +161,8 @@ public async Task RefreshChatAsync(IShell shell, bool force)
161
161
{
162
162
IHost host = shell . Host ;
163
163
CancellationToken cancellationToken = shell . CancellationToken ;
164
+
165
+ _copilotResponse = null ;
164
166
ResetArgumentPlaceholder ( ) ;
165
167
166
168
try
@@ -214,6 +216,9 @@ public async Task<bool> ChatAsync(string input, IShell shell)
214
216
IHost host = shell . Host ;
215
217
CancellationToken token = shell . CancellationToken ;
216
218
219
+ _copilotResponse = null ;
220
+ ResetArgumentPlaceholder ( ) ;
221
+
217
222
if ( _turnsLeft is 0 )
218
223
{
219
224
host . WriteLine ( "\n Sorry, you've reached the maximum length of a conversation. Please run '/refresh' to start a new conversation.\n " ) ;
@@ -243,8 +248,6 @@ public async Task<bool> ChatAsync(string input, IShell shell)
243
248
244
249
if ( _copilotResponse . ChunkReader is null )
245
250
{
246
- ResetArgumentPlaceholder ( ) ;
247
-
248
251
if ( _copilotResponse . IsError )
249
252
{
250
253
string errorMessage = _copilotResponse . Text ;
@@ -325,11 +328,22 @@ public async Task<bool> ChatAsync(string input, IShell shell)
325
328
326
329
Telemetry . Trace ( AzTrace . Chat ( _copilotResponse ) ) ;
327
330
}
328
- catch ( Exception ex ) when ( ex is TokenRequestException or ConnectionDroppedException )
331
+ catch ( Exception ex )
329
332
{
330
- host . WriteErrorLine ( ex . Message ) ;
331
- host . WriteErrorLine ( "Please run '/refresh' to start a new chat session and try again." ) ;
332
- return false ;
333
+ if ( ex is TokenRequestException or ConnectionDroppedException )
334
+ {
335
+ host . WriteErrorLine ( ex . Message ) ;
336
+ host . WriteErrorLine ( "Please run '/refresh' to start a new chat session and try again." ) ;
337
+ return false ;
338
+ }
339
+
340
+ Log . Error ( ex , "Exception thrown when processing the query '{0}'" , input ) ;
341
+ if ( _copilotResponse ? . Text is not null )
342
+ {
343
+ Log . Error ( "Response text:\n {0}" , _copilotResponse . Text ) ;
344
+ }
345
+
346
+ throw ;
333
347
}
334
348
335
349
return true ;
0 commit comments