[303] refactor(errors): adopt 3-line standard (error / caused by / help)#306
Merged
Conversation
Issue #303. Add the infrastructure for the standard error format and wire main.rs to render it. Existing call sites keep rendering as a single line — migration is gradual (see docs/error-format.md). Changes: - `ParsecError` gains `caused_by: Option<String>` and `help: Option<String>` fields plus builder-style setters (`with_caused_by`, `with_help`). `Display` now writes one to three lines depending on which fields are populated. - `JsonError` gains the same two fields with `skip_serializing_if = "Option::is_none"` so existing `--json` consumers see no schema change. - `extract_full(&anyhow::Error) -> Option<&ParsecError>` helper for new callers; the legacy `extract_code` is kept untouched. - `main.rs` prefers the typed error: when the error is a `ParsecError`, print it directly (its `Display` already includes the `error:` prefix + code); otherwise fall back to the legacy single-line `error: {err:#}`. - `bail_code!` macro unchanged (for the "summary only" case). - `docs/error-format.md` documents the format, builder API, JSON shape, recipes, and what NOT to do. Tests: +9 in `errors::tests` covering 1/2/3-line display, help-only, extract_full happy/None, backward-compat extract_code, JSON skip-if-none, JSON with-fields, bail_code macro round-trip. Full suite 53 + 5 + 40 = 98 pass, fmt clean. Migration: any existing `ParsecError::new(...)` site can opt in by chaining `.with_caused_by(...)` and/or `.with_help(...)`. Prioritize cli/commands/ and worktree/ first (highest user contact).
…act_code Clippy `-D warnings` flagged `with_caused_by`, `with_help`, and `extract_code` as never-used. Phase 1 of #303 is the infra-only PR — call sites land in follow-up PRs. Annotation matches the existing `#[allow(dead_code)]` on `ErrorCode` for the same forward-looking reason.
4 tasks
This was referenced May 25, 2026
erishforG
added a commit
that referenced
this pull request
May 25, 2026
…317) develop에 머지됐지만 CHANGELOG.md [Unreleased]에 누락된 항목 4개를 추가한다: - parsec smartlog (alias sl): commit DAG 시각화 (#245, #305) - parsec __complete: 동적 shell completion 헬퍼 (#291, #312) - 에러 메시지 3줄 표준화 (error/caused by/help) (#303, #306) - Windows VS2026 pre-validation CI job (#307, #311) Closes #316 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
`parsec` 의 user-facing 에러를 error: / caused by: / help: 3-line 포맷으로 표준화 (#303). 첫 사용자 마찰 ↓.
변경
출력 예
```
error: workspace 'CL-2283' not found [E005]
caused by: directory missing or .git/parsec/state.json out of sync (...)
help: run `parsec doctor`, or `parsec clean --orphans` to drop stale state
```
JSON:
```json
{ "error": true, "code": "E005", "message": "...", "caused_by": "...", "help": "..." }
```
테스트
마이그레이션
관련
🤖 Generated with Claude Code