diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-14 11:24:36 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-21 13:41:27 +0200 |
| commit | 0b3e5f5bd42a02c2a15b394b3768e517dc43f39c (patch) | |
| tree | 578f95913a12eebda908384f45e1d0e27977ba20 /internal/llm/tools/fetch.go | |
| parent | 921f5ee5bd74837ff4566fc2d1e45051c87d9c38 (diff) | |
| download | opencode-0b3e5f5bd42a02c2a15b394b3768e517dc43f39c.tar.gz opencode-0b3e5f5bd42a02c2a15b394b3768e517dc43f39c.zip | |
handle errors correctly in the other tools
Diffstat (limited to 'internal/llm/tools/fetch.go')
| -rw-r--r-- | internal/llm/tools/fetch.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/llm/tools/fetch.go b/internal/llm/tools/fetch.go index 19e644281..91bcb36a0 100644 --- a/internal/llm/tools/fetch.go +++ b/internal/llm/tools/fetch.go @@ -86,6 +86,7 @@ func (t *fetchTool) Info() ToolInfo { "format": map[string]any{ "type": "string", "description": "The format to return the content in (text, markdown, or html)", + "enum": []string{"text", "markdown", "html"}, }, "timeout": map[string]any{ "type": "number", @@ -126,7 +127,7 @@ func (t *fetchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error ) if !p { - return NewTextErrorResponse("Permission denied to fetch from URL: " + params.URL), nil + return ToolResponse{}, permission.ErrorPermissionDenied } client := t.client @@ -142,14 +143,14 @@ func (t *fetchTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error req, err := http.NewRequestWithContext(ctx, "GET", params.URL, nil) if err != nil { - return NewTextErrorResponse("Failed to create request: " + err.Error()), nil + return ToolResponse{}, fmt.Errorf("failed to create request: %w", err) } req.Header.Set("User-Agent", "termai/1.0") resp, err := client.Do(req) if err != nil { - return NewTextErrorResponse("Failed to execute request: " + err.Error()), nil + return ToolResponse{}, fmt.Errorf("failed to fetch URL: %w", err) } defer resp.Body.Close() |
