Skip to content

fix: use PowerMemError instead of generic Error in NativeProvider.update#9

Merged
Evenss merged 1 commit intoob-labs:mainfrom
knqiufan:fix/update-error-type
Apr 7, 2026
Merged

fix: use PowerMemError instead of generic Error in NativeProvider.update#9
Evenss merged 1 commit intoob-labs:mainfrom
knqiufan:fix/update-error-type

Conversation

@knqiufan
Copy link
Copy Markdown
Contributor

@knqiufan knqiufan commented Apr 3, 2026

Summary

  • NativeProvider.update() threw a plain Error when the memory ID was not found, making it impossible for callers to catch domain errors via instanceof PowerMemError
  • Replaced with PowerMemError using code 'NOT_FOUND', aligning with the project's custom error hierarchy
  • Updated existing tests to also assert on PowerMemError type

Changes

  • src/core/native-provider.ts: import PowerMemError, replace throw new Error(...) with throw new PowerMemError(..., 'NOT_FOUND')
  • tests/integration/coverage-gaps.test.ts: add toBeInstanceOf(PowerMemError) assertion
  • tests/regression/edge-cases.test.ts: add toBeInstanceOf(PowerMemError) assertions for both invalid ID cases

Test plan

  • All 339 existing tests pass
  • Updated tests verify error is instanceof PowerMemError
  • Error message text unchanged ('Memory not found: <id>')

NativeProvider.update() threw a plain Error when the memory ID was not
found, making it impossible for callers to distinguish domain errors via
instanceof PowerMemError. Align with the project's custom error hierarchy
by throwing PowerMemError with code 'NOT_FOUND'.
Copy link
Copy Markdown
Collaborator

@Evenss Evenss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Evenss Evenss merged commit 874a7ac into ob-labs:main Apr 7, 2026
6 of 7 checks passed
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.

2 participants