Skip to content

fix: Clear error messages with structured errors and suggestions#364

Open
whitmo wants to merge 1 commit intodlorenc:mainfrom
whitmo:multiclaude/swift-bear
Open

fix: Clear error messages with structured errors and suggestions#364
whitmo wants to merge 1 commit intodlorenc:mainfrom
whitmo:multiclaude/swift-bear

Conversation

@whitmo
Copy link
Copy Markdown

@whitmo whitmo commented Mar 3, 2026

Summary

  • P0 Roadmap item: "Clear error messages - Every failure should tell the user what went wrong and how to fix it"
  • Audited internal/cli/cli.go (~5500 lines) and internal/daemon/daemon.go for raw errors lacking user context
  • Converted ~70 raw fmt.Errorf calls to use structured internal/errors constructors with categories, messages, and actionable suggestions
  • Added 7 new error constructors and improved daemon socket response messages with recovery hints

Key improvements by failure path:

  • Daemon not running: DaemonCommunicationFailed() with "multiclaude daemon start" suggestion (replaces "failed to X: %w (is daemon running?)")
  • Agent/worker not found: Existing AgentNotFound() used more consistently, new AgentRestartFailed()
  • Worktree issues: WorktreeCreationFailed() used in all paths, cleanup suggestions
  • Tmux failures: TmuxOperationFailed() with manual cleanup commands
  • Claude binary: ClaudeNotFound() and new ClaudeStartupFailed() with install link
  • Validation: InvalidArgument() for all flag validation (--mq-track, --ps-enabled, etc.)

New error constructors:

ClaudeStartupFailed, DaemonAlreadyRunning, AgentRestartFailed, PromptWriteFailed, LogFileNotFound, WorkspaceAlreadyExists, RepoAlreadyInitialized

Test plan

  • All existing tests pass (go test ./...)
  • New constructor tests added and passing
  • Build compiles cleanly
  • Error formatting verified via existing Format() tests

🤖 Generated with Claude Code

Audit and improve error messages in cli.go and daemon.go for the P0
"Clear error messages" roadmap item. Every failure now tells the user
what went wrong and how to fix it.

Changes:
- Add 7 new error constructors: ClaudeStartupFailed, DaemonAlreadyRunning,
  AgentRestartFailed, PromptWriteFailed, LogFileNotFound,
  WorkspaceAlreadyExists, RepoAlreadyInitialized
- Convert ~70 raw fmt.Errorf calls in cli.go to use structured errors
  with categories, messages, and actionable suggestions
- Improve daemon.go socket error responses with recovery hints
- Focus on most common failure paths: daemon communication, agent/worker
  not found, worktree issues, tmux failures, Claude binary not found
- Add tests for all new error constructors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@whitmo
Copy link
Copy Markdown
Author

whitmo commented Mar 7, 2026

Triage Review

Priority: P0 (Clear error messages - roadmap item)
Build: Pass
Tests: Pass (errors + cli packages)
Merge conflicts: Conflicts with PR #360 (cli.go) and PR #362 (daemon.go)
Roadmap alignment: Directly addresses P0 "Clear error messages" item

Changes:

  • Converts ~30 raw fmt.Errorf calls to structured errors.* constructors
  • Adds new error constructors: RepoAlreadyInitialized, InvalidArgument, PromptWriteFailed, ClaudeNotFound, ClaudeStartupFailed
  • Each error includes actionable suggestions for the user

Recommendation: Merge AFTER #360 and #362 to avoid conflicts, then rebase.

@whitmo
Copy link
Copy Markdown
Author

whitmo commented Mar 12, 2026

Local CI Verification (2026-03-12)

Check Result
go build PASS
go vet PASS
go test ./... PASS (all packages)

CI Status: No GitHub Actions checks are running — this is expected for first-time fork PRs. GitHub requires a maintainer to approve workflow runs for PRs from forks.

Branch is rebased on upstream/main (0 commits behind). Ready for maintainer review and CI approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant