core icon indicating copy to clipboard operation
core copied to clipboard

feat: keyring controller error

Open montelaidev opened this issue 2 months ago • 0 comments

Explanation

References

Checklist

  • [ ] I've updated the test suite for new or updated code as appropriate
  • [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • [ ] I've communicated my changes to consumers by updating changelogs for packages I've changed
  • [ ] I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

[!NOTE] Introduces KeyringControllerError with codes/data/causes and refactors the controller and tests to use it, improving error wrapping and stability.

  • Core (keyring-controller):
    • New error class: Add src/errors.ts defining KeyringControllerError (supports code, data, cause and legacy originalError, JSON/string serialization).
    • Error refactor: Replace generic Error throws with KeyringControllerError across src/KeyringController.ts (e.g., exportSeedPhrase, exportAccount, signing, user ops, vault ops, validation helpers).
    • Improved wrapping: signTypedMessage now wraps underlying errors with KeyringControllerError, preserving original cause.
    • Misc: Minor guard/typing tweaks (explicit HD type checks) and internal deadlock-safe state-change listener logic in tests.
  • Tests:
    • Update expectations to use KeyringControllerError class and KeyringControllerError messages from ./constants.
    • Add comprehensive tests for error codes/data/causes and propagation from hardware keyrings.
  • Config:
    • Increase Jest coverage threshold for branches to 95.5 in jest.config.js.

Written by Cursor Bugbot for commit a1c8b4ffe417e6bde30cc89742d370f20bc01c7e. This will update automatically on new commits. Configure here.

montelaidev avatar Dec 15 '25 15:12 montelaidev