Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(permission-controller): Re-throw all well-formed errors #4172

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented Apr 16, 2024

Explanation

When re-throwing validation errors in requestPermissions(), include original message from all well-formed errors. Also restore 100% unit test coverage.

Changelog

@metamask/permission-controller

  • ADDED: Make permission request validation errors more informative

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 highlighted breaking changes using the "BREAKING" category above as appropriate

@rekmarks rekmarks requested a review from a team as a code owner April 16, 2024 18:47
@rekmarks rekmarks force-pushed the rekmarks-re-throw-permission-validation-errors branch 2 times, most recently from 01612bb to 28f86e9 Compare April 16, 2024 21:49
Re-throws all well-formed errors during that occur during permission
validation in `requestPermissions()`. Also restores 100% unit test
coverage.
@rekmarks rekmarks force-pushed the rekmarks-re-throw-permission-validation-errors branch from 28f86e9 to 442d128 Compare April 17, 2024 15:25
const callActionSpy = jest
.spyOn(messenger, 'call')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.mockImplementationOnce(async (...args: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why couldn't args be typed properly?

Copy link
Member Author

@rekmarks rekmarks Apr 17, 2024

Choose a reason for hiding this comment

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

I tried to add a more specific type, but got a pretty inscrutable error as a result. I could try to debug that, but if we somehow mess up these mocks, the tests ought to fail in unexpected ways, which we would immediately discover. It probably could be done, but I don't think it's worth our time.

Edit: This is also just what we already do for similar mocks throughout this file, and I remove all of the TODOs to remove these any's here: #4171

@rekmarks rekmarks merged commit 1536fce into main Apr 17, 2024
139 checks passed
@rekmarks rekmarks deleted the rekmarks-re-throw-permission-validation-errors branch April 17, 2024 22:06
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.

3 participants