[PR #6801] fix(memory-adapter): replace generic Error with typed error #6891

Open
opened 2026-03-13 13:15:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6801
Author: @MuzzaiyyanHussain
Created: 12/16/2025
Status: 🔄 Open

Base: canaryHead: fix/memory-adapter-typed-error


📝 Commits (5)

  • f3d8c18 fix(memory-adapter): consistently use MemoryAdapterError
  • 15aec15 test(memory-adapter): cover MODEL_NOT_FOUND error case
  • 1b617fb test(memory-adapter): use expect.rejects.toThrow
  • d10c34d test(memory-adapter): use toThrowError for error assertions
  • e045c1f Merge branch 'canary' into fix/memory-adapter-typed-error

📊 Changes

2 files changed (+91 additions, -21 deletions)

View changed files

📝 packages/better-auth/src/adapters/memory-adapter/memory-adapter.ts (+75 -21)
packages/better-auth/src/adapters/tests/memory-adapter.error.test.ts (+16 -0)

📄 Description

Replaces generic Error throws in the memory adapter with a typed MemoryAdapterError.

This improves error semantics and developer experience without changing runtime behavior.


Summary by cubic

Added a typed MemoryAdapterError in the memory adapter to standardize error codes and messages. Improves debugging and consistency across methods.

  • Bug Fixes
    • Introduced MemoryAdapterError with codes: MODEL_NOT_FOUND, INVALID_OPERATOR_VALUE, JOIN_MODEL_NOT_FOUND.
    • count and findOne now throw MODEL_NOT_FOUND when the model is missing; "in"/"not_in" throw INVALID_OPERATOR_VALUE if the value is not an array.

Written for commit e045c1f024. 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/6801 **Author:** [@MuzzaiyyanHussain](https://github.com/MuzzaiyyanHussain) **Created:** 12/16/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `fix/memory-adapter-typed-error` --- ### 📝 Commits (5) - [`f3d8c18`](https://github.com/better-auth/better-auth/commit/f3d8c1816e49601ae5704d3b663320ab60b329da) fix(memory-adapter): consistently use MemoryAdapterError - [`15aec15`](https://github.com/better-auth/better-auth/commit/15aec15290a4e286e3e1d20b196c577651202be1) test(memory-adapter): cover MODEL_NOT_FOUND error case - [`1b617fb`](https://github.com/better-auth/better-auth/commit/1b617fb9d420f04d54c4663ea0ac43f7f1242c2a) test(memory-adapter): use expect.rejects.toThrow - [`d10c34d`](https://github.com/better-auth/better-auth/commit/d10c34db6ea517ead3687646d4f3e3e07bdc6c67) test(memory-adapter): use toThrowError for error assertions - [`e045c1f`](https://github.com/better-auth/better-auth/commit/e045c1f0242a935e6523b8f13e49bfc293751c33) Merge branch 'canary' into fix/memory-adapter-typed-error ### 📊 Changes **2 files changed** (+91 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/memory-adapter/memory-adapter.ts` (+75 -21) ➕ `packages/better-auth/src/adapters/tests/memory-adapter.error.test.ts` (+16 -0) </details> ### 📄 Description Replaces generic Error throws in the memory adapter with a typed MemoryAdapterError. This improves error semantics and developer experience without changing runtime behavior. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added a typed MemoryAdapterError in the memory adapter to standardize error codes and messages. Improves debugging and consistency across methods. - **Bug Fixes** - Introduced MemoryAdapterError with codes: MODEL_NOT_FOUND, INVALID_OPERATOR_VALUE, JOIN_MODEL_NOT_FOUND. - count and findOne now throw MODEL_NOT_FOUND when the model is missing; "in"/"not_in" throw INVALID_OPERATOR_VALUE if the value is not an array. <sup>Written for commit e045c1f0242a935e6523b8f13e49bfc293751c33. 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:15:56 -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#6891