Skip to content

Extract duplicate constraint-error handler in personalities.ts - #602

Merged
selfcontained merged 1 commit into
mainfrom
agt_4970eb78c862/job-debt-collector-88c5cd55
May 23, 2026
Merged

Extract duplicate constraint-error handler in personalities.ts#602
selfcontained merged 1 commit into
mainfrom
agt_4970eb78c862/job-debt-collector-88c5cd55

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

  • Extracted a throwUnlessDuplicateName helper in personalities.ts to deduplicate identical catch blocks in the POST and PATCH routes for handling the personalities_name_key unique constraint violation
  • Adopted the shared errorMessage() utility from shared/lib/error-message.ts instead of inline error instanceof Error ? error.message : "" checks
  • Net: 2 fewer lines, one source of truth for constraint-error handling in this file

Why this is tech debt

Both catch blocks were byte-for-byte identical — any change to the error message or status code had to be made in two places. The inline instanceof check also bypassed the shared errorMessage() helper that prior tech-debt runs established as the project convention.

Next up

The next tech-debt run will address incomplete adoption of the shared errorMessage() helper in agents.ts and templates.ts (backlog item #3).

Test plan

  • pnpm run check — TypeScript type checking passes
  • pnpm run test — All 95 unit tests pass
  • pnpm run test:e2e — All 160 E2E tests pass (12 pre-existing skips)

🤖 Generated with Claude Code

Both POST and PATCH routes had identical catch blocks for the
personalities_name_key constraint violation. Extract a shared
throwUnlessDuplicateName helper and adopt the shared errorMessage()
utility instead of inline instanceof checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit 9f4a276 into main May 23, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_4970eb78c862/job-debt-collector-88c5cd55 branch May 23, 2026 16:20
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