rename recover

This commit is contained in:
linhaolin1 2026-03-17 20:34:04 +08:00
parent 72a34dcdf2
commit 314090d649

View file

@ -85,18 +85,18 @@ func (r *ToolRegistry) ExecuteWithContext(
var result *ToolResult
func() {
defer func() {
if r := recover(); r != nil {
errMsg := fmt.Sprintf("Tool '%s' crashed with panic: %v", name, r)
if re := recover(); re != nil {
errMsg := fmt.Sprintf("Tool '%s' crashed with panic: %v", name, re)
logger.ErrorCF("tool", "Tool execution panic recovered",
map[string]any{
"tool": name,
"panic": fmt.Sprintf("%v", r),
"panic": fmt.Sprintf("%v", re),
})
result = &ToolResult{
ForLLM: errMsg,
ForUser: errMsg,
IsError: true,
Err: fmt.Errorf("panic: %v", r),
Err: fmt.Errorf("panic: %v", re),
}
}
}()