Skip to content

Commit 63c62d9

Browse files
committed
Print out the messages from inner exceptions
1 parent 238b434 commit 63c62d9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

shell/AIShell.Kernel/Shell.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Text;
23
using AIShell.Abstraction;
34
using AIShell.Kernel.Commands;
45
using AIShell.Kernel.Mcp;
@@ -686,8 +687,24 @@ internal async Task RunREPLAsync()
686687
continue;
687688
}
688689

690+
StringBuilder sb = null;
691+
string message = ex.Message;
692+
string stackTrace = ex.StackTrace;
693+
694+
while (ex.InnerException is { })
695+
{
696+
sb ??= new(message, capacity: message.Length * 3);
697+
sb.Append($"\n Inner -> {ex.InnerException.Message}");
698+
ex = ex.InnerException;
699+
}
700+
701+
if (sb is not null)
702+
{
703+
message = sb.ToString();
704+
}
705+
689706
Host.WriteErrorLine()
690-
.WriteErrorLine($"Agent failed to generate a response: {ex.Message}\n{ex.StackTrace}")
707+
.WriteErrorLine($"Agent failed to generate a response: {message}\n\n{stackTrace}")
691708
.WriteErrorLine();
692709
}
693710
}

0 commit comments

Comments
 (0)