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

Improve keyring endowment error messaging #884

Merged
merged 5 commits into from Oct 28, 2022

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Oct 28, 2022

Previously, if a Snap would specify an invalid keyring namespace object, we would throw an error like:

Expected a valid namespaces object.

This does not explain exactly what the issue is. This changes it to throw more descriptive errors, i.e., the errors thrown by Superstruct, but wrapped in a JSON-RPC error. For example:

Invalid namespaces object: Expected an object, but received: undefined.

@Mrtenz Mrtenz requested a review from a team as a code owner October 28, 2022 17:50
ritave
ritave previously approved these changes Oct 28, 2022
Copy link
Member

@ritave ritave left a comment

Choose a reason for hiding this comment

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

Approved with optional improvements

throw ethErrors.rpc.invalidParams({
message: 'Expected a valid namespaces object.',
message: `Invalid namespaces object: ${error.message}.`,
Copy link
Member

Choose a reason for hiding this comment

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

Superstruct validates errors lazily, if you want, we could show all of them. error.failures() returns a list of all of them all

packages/utils/src/namespace.ts Show resolved Hide resolved
packages/utils/src/assert.ts Outdated Show resolved Hide resolved
packages/utils/src/assert.ts Show resolved Hide resolved
@MetaMask MetaMask deleted a comment from nyi851 Oct 28, 2022
@Mrtenz Mrtenz merged commit 968bfd6 into main Oct 28, 2022
@Mrtenz Mrtenz deleted the mrtenz/keyring-error-messaging branch October 28, 2022 19:04
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.

None yet

2 participants