Skip to content

Add Unwrap() to printedError for proper error chain support#15

Merged
JulienTant merged 2 commits intomainfrom
worktree-agent-adcd3d8b
Apr 4, 2026
Merged

Add Unwrap() to printedError for proper error chain support#15
JulienTant merged 2 commits intomainfrom
worktree-agent-adcd3d8b

Conversation

@JulienTant
Copy link
Copy Markdown
Owner

@JulienTant JulienTant commented Apr 4, 2026

Summary

  • Adds Unwrap() method to printedError so errors.Is() and errors.As() can see through to wrapped controller error types
  • Adds 8 unit tests for printedError wrapping behavior (internal/cli/errors_test.go)
  • Adds 6 unit tests for controller error type messages and fmt.Errorf wrapping (internal/controller/errors_test.go)

Test plan

  • All 62 tests pass (48 existing + 14 new)
  • golangci-lint reports 0 issues
  • E2E golden files require no updates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit test coverage for error handling and message formatting to ensure proper error reporting.

Without Unwrap(), errors.Is() and errors.As() cannot see through
printedError to match wrapped controller error types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 06cfeb88-a292-4a8d-b38b-9fea91e1f5d5

📥 Commits

Reviewing files that changed from the base of the PR and between 52fb078 and 363e862.

📒 Files selected for processing (3)
  • internal/cli/errors.go
  • internal/cli/errors_test.go
  • internal/controller/errors_test.go

📝 Walkthrough

Walkthrough

The PR adds an Unwrap() method to the CLI error wrapper and introduces comprehensive test coverage for error handling in both CLI and controller packages, enabling standard Go error inspection via errors.Unwrap, errors.Is, and errors.As.

Changes

Cohort / File(s) Summary
CLI Error Handling
internal/cli/errors.go, internal/cli/errors_test.go
Added Unwrap() method to printedError to expose the underlying error; comprehensive test suite validates error marking, identity semantics, wrapping/unwrapping behavior, and extraction of controller error types (BlogNotFoundError, BlogAlreadyExistsError, ArticleNotFoundError) with field preservation.
Controller Error Testing
internal/controller/errors_test.go
New test suite verifies error message formatting for custom error types and confirms each error can be extracted from fmt.Errorf wrapped errors with original data fields preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Errors unwrapped with graceful care,
No longer hidden, all laid bare,
The rabbit hops through Go's unwrap dance,
Letting errors show their true stance!
Testing proves each field stays true,
Nested errors shine right through!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding an Unwrap() method to printedError for error chain support.
Description check ✅ Passed The description includes all required sections with substantive content: Summary explains the changes, Test plan confirms testing with checkboxes and specific results.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-agent-adcd3d8b

Comment @coderabbitai help to get the list of available commands and usage tips.

@JulienTant JulienTant merged commit a7b3f82 into main Apr 4, 2026
2 checks passed
@JulienTant JulienTant deleted the worktree-agent-adcd3d8b branch April 4, 2026 02:18
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