feat: extract error handling helpers FatalError/WarnError (bd-s0z)

Create reusable error handling helpers to reduce boilerplate and
enforce consistency across the codebase:

- FatalError(format, args...): writes "Error: ..." to stderr and exits
- FatalErrorWithHint(message, hint): includes actionable suggestion
- WarnError(format, args...): writes "Warning: ..." to stderr

Prototyped in create.go to validate the approach - converted 13 error
patterns and 5 warning patterns. This reduces code from:

    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    os.Exit(1)

To simply:

    FatalError("%v", err)

Also fixed countIssuesInJSONLFile reference after earlier refactoring.

See docs/ERROR_HANDLING.md for the three-pattern guideline.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-28 23:28:30 -08:00
parent 0ab815dd5a
commit cd114b7bd5
4 changed files with 150 additions and 106 deletions

View File

@@ -1395,6 +1395,13 @@ Aborting.`, yellow("⚠"), filepath.Base(jsonlPath), issueCount, cyan("bd doctor
return nil // No existing data found, safe to init
}
// countIssuesInJSONLFile counts the number of issues in a JSONL file.
// Delegates to countJSONLIssues in doctor.go.
func countIssuesInJSONLFile(jsonlPath string) int {
count, _, _ := countJSONLIssues(jsonlPath)
return count
}
// setupClaudeSettings creates or updates .claude/settings.local.json with onboard instruction
func setupClaudeSettings(verbose bool) error {
claudeDir := ".claude"