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/view.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/view.go')
| -rw-r--r-- | internal/llm/tools/view.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/llm/tools/view.go b/internal/llm/tools/view.go index a0600a2a1..7450a84bf 100644 --- a/internal/llm/tools/view.go +++ b/internal/llm/tools/view.go @@ -135,7 +135,7 @@ func (v *viewTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error) return NewTextErrorResponse(fmt.Sprintf("File not found: %s", filePath)), nil } - return NewTextErrorResponse(fmt.Sprintf("Failed to access file: %s", err)), nil + return ToolResponse{}, fmt.Errorf("error accessing file: %w", err) } // Check if it's a directory @@ -156,6 +156,7 @@ func (v *viewTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error) // Check if it's an image file isImage, imageType := isImageFile(filePath) + // TODO: handle images if isImage { return NewTextErrorResponse(fmt.Sprintf("This is an image file of type: %s\nUse a different tool to process images", imageType)), nil } @@ -163,7 +164,7 @@ func (v *viewTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error) // Read the file content content, lineCount, err := readTextFile(filePath, params.Offset, params.Limit) if err != nil { - return NewTextErrorResponse(fmt.Sprintf("Failed to read file: %s", err)), nil + return ToolResponse{}, fmt.Errorf("error reading file: %w", err) } notifyLspOpenFile(ctx, filePath, v.lspClients) |
