Skip to content

DRY: extract shared error-handling helpers#35

Open
clockblocker wants to merge 1 commit intomasterfrom
nightshift/auto-dry-v4
Open

DRY: extract shared error-handling helpers#35
clockblocker wants to merge 1 commit intomasterfrom
nightshift/auto-dry-v4

Conversation

@clockblocker
Copy link
Copy Markdown
Owner

Summary

  • Added extractErrorReason() and toApiCommandError() to errors.ts — centralizes the repeated "reason" in error ? ... ternary (4 occurrences) and ResultAsync.fromPromise error conversion (2 occurrences)
  • Added notifyAndLogError() in orchestration/shared/notify-error.ts — replaces 3 identical .mapErr() blocks that notify the user and log the error
  • Net result: 6 files changed, 42 insertions, 43 deletions (removed more code than added)

Files changed

File Change
errors.ts Added extractErrorReason, toApiCommandError helpers
orchestration/shared/notify-error.ts New file: notifyAndLogError helper
textfresser.ts Use notifyAndLogError instead of inline .mapErr()
orchestration/lemma/execute-lemma-flow.ts Use notifyAndLogError in both error paths
orchestration/background/background-generate-coordinator.ts Use extractErrorReason
commands/generate/steps/generate-sections.ts Use toApiCommandError for both ResultAsync.fromPromise calls

Test plan

  • TypeScript type check passes (no new errors)
  • All 1150 unit tests pass (6 pre-existing failures unchanged)
  • Biome lint passes on all modified files
  • Pure structural refactor — no behavior changes

🤖 Generated with Claude Code

Add extractErrorReason() and toApiCommandError() to errors.ts, and
notifyAndLogError() to orchestration/shared/notify-error.ts. Replace
4 inline "reason" in error ternaries and 3 identical .mapErr() blocks
across textfresser.ts, execute-lemma-flow.ts, background-generate-coordinator.ts,
and generate-sections.ts.

Nightshift-Task: auto-dry
Nightshift-Ref: https://github.com/marcus/nightshift

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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