From e2112e627ca726942443ae7d4c2099fe0b67a909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Mon, 8 Jun 2026 17:27:31 +0800 Subject: [PATCH] fix: use %w for error wrapping and handle json.MarshalIndent error --- cmd/picoclaw/internal/skills/helpers.go | 2 +- pkg/tools/integration/web.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/picoclaw/internal/skills/helpers.go b/cmd/picoclaw/internal/skills/helpers.go index 0ec602005..dad168e7c 100644 --- a/cmd/picoclaw/internal/skills/helpers.go +++ b/cmd/picoclaw/internal/skills/helpers.go @@ -79,7 +79,7 @@ func skillsInstallFromRegistry(cfg *config.Config, registryName, target string) defer cancel() if err = os.MkdirAll(filepath.Join(workspace, "skills"), 0o755); err != nil { - return fmt.Errorf("\u2717 failed to create skills directory: %v", err) + return fmt.Errorf("\u2717 failed to create skills directory: %w", err) } result, err := registry.DownloadAndInstall(ctx, target, "", targetDir) diff --git a/pkg/tools/integration/web.go b/pkg/tools/integration/web.go index 4a50d3e55..24c97a463 100644 --- a/pkg/tools/integration/web.go +++ b/pkg/tools/integration/web.go @@ -2275,7 +2275,10 @@ func (t *WebFetchTool) Execute(ctx context.Context, args map[string]any) *ToolRe "text": text, } - resultJSON, _ := json.MarshalIndent(result, "", " ") + resultJSON, marshalErr := json.MarshalIndent(result, "", " ") + if marshalErr != nil { + return ErrorResult(fmt.Sprintf("failed to marshal result: %v", marshalErr)) + } return &ToolResult{ ForLLM: string(resultJSON),