fix(seahorse): handle json.Marshal errors in grep and expand tools
This commit is contained in:
parent
cf67dd3851
commit
ed55715b6b
2 changed files with 8 additions and 2 deletions
|
|
@ -124,6 +124,9 @@ func (t *ExpandTool) Execute(ctx context.Context, args map[string]any) *tools.To
|
||||||
"tokenCount": result.TokenCount,
|
"tokenCount": result.TokenCount,
|
||||||
"messages": messages,
|
"messages": messages,
|
||||||
}
|
}
|
||||||
data, _ := json.Marshal(output)
|
data, err := json.Marshal(output)
|
||||||
|
if err != nil {
|
||||||
|
return tools.ErrorResult(fmt.Sprintf("failed to marshal expand result: %v", err))
|
||||||
|
}
|
||||||
return tools.NewToolResult(string(data))
|
return tools.NewToolResult(string(data))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,9 @@ func (t *GrepTool) Execute(ctx context.Context, args map[string]any) *tools.Tool
|
||||||
output["hint"] = result.Hint
|
output["hint"] = result.Hint
|
||||||
}
|
}
|
||||||
|
|
||||||
data, _ := json.Marshal(output)
|
data, err := json.Marshal(output)
|
||||||
|
if err != nil {
|
||||||
|
return tools.ErrorResult(fmt.Sprintf("failed to marshal grep result: %v", err))
|
||||||
|
}
|
||||||
return tools.NewToolResult(string(data))
|
return tools.NewToolResult(string(data))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue