[PR #7636] [MERGED] chore: use more APIError.from #7456

Closed
opened 2026-03-13 13:37:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7636
Author: @himself65
Created: 1/27/2026
Status: Merged
Merged: 1/27/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/27/error-code


📝 Commits (1)

📊 Changes

4 files changed (+9 additions, -9 deletions)

View changed files

📝 packages/better-auth/src/api/middlewares/origin-check.ts (+1 -1)
📝 packages/better-auth/src/api/routes/password.ts (+1 -1)
📝 packages/better-auth/src/api/routes/update-user.ts (+5 -7)
📝 packages/core/src/error/codes.ts (+2 -0)

📄 Description

Summary by cubic

Standardized error handling by switching to APIError.from and BASE_ERROR_CODES in origin checks, password verification, and user update routes. This makes error responses consistent and easier to consume.

  • Refactors
    • Origin check: FORBIDDEN with INVALID_ORIGIN.
    • verifyPassword: BAD_REQUEST with INVALID_PASSWORD.
    • updateUser body validation: BAD_REQUEST with BODY_MUST_BE_AN_OBJECT.
    • setPassword: BAD_REQUEST with PASSWORD_ALREADY_SET.

Written for commit 5f1d776b8b. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7636 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/27/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/27/error-code` --- ### 📝 Commits (1) - [`5f1d776`](https://github.com/better-auth/better-auth/commit/5f1d776b8b648cdafb7671ca27dd2183f1f3c879) chore: use `APIError.from` ### 📊 Changes **4 files changed** (+9 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/middlewares/origin-check.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/password.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+5 -7) 📝 `packages/core/src/error/codes.ts` (+2 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Standardized error handling by switching to APIError.from and BASE_ERROR_CODES in origin checks, password verification, and user update routes. This makes error responses consistent and easier to consume. - **Refactors** - Origin check: FORBIDDEN with INVALID_ORIGIN. - verifyPassword: BAD_REQUEST with INVALID_PASSWORD. - updateUser body validation: BAD_REQUEST with BODY_MUST_BE_AN_OBJECT. - setPassword: BAD_REQUEST with PASSWORD_ALREADY_SET. <sup>Written for commit 5f1d776b8b648cdafb7671ca27dd2183f1f3c879. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:37:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7456