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

Fix RPC error messages #7173

Merged
merged 4 commits into from
Sep 19, 2019
Merged

Fix RPC error messages #7173

merged 4 commits into from
Sep 19, 2019

Conversation

rekmarks
Copy link
Member

@rekmarks rekmarks commented Sep 16, 2019

Fix error message issues described in: #7138 (comment)

9/18/2019 update: Ready to review.

Pending

In a previous commit, json-rpc-engine started using eth-json-rpc-errors for error serialization. This error serialization swallowed the original error message if the error had a missing or invalid code. The above PR to json-rpc-engine preserves the original error message if it exists and adds a valid code (JSON RPC Internal error, -32603) if the original code was missing/invalid.

With that change and the code changes introduced in this PR, all RPC errors returned from the extension to the inpage provider will follow JSON RPC 2.0 and EIP 1193, allowing dapp devs to identify and handle errors by code. Consistently using the eth-json-rpc-errors API internally will allow us to do the same.

Gudahtt
Gudahtt previously approved these changes Sep 16, 2019
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Looks good! It works for me locally.

@Gudahtt
Copy link
Member

Gudahtt commented Sep 16, 2019

I suspect this closes #7160

@tmashuang
Copy link
Contributor

I didn't even see #7160. Seems that it fixed the provider approval error, but not the signing methods they mentioned.
Is this where the error handling should go in their respective files?

case 'rejected':
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))

case 'rejected':
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))

case 'rejected':
return reject(new Error('MetaMask Message Signature: User denied message signature.'))
case 'errored':
return reject(new Error(`MetaMask Message Signature: ${data.error}`))
default:
return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))

Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

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

I noticed one typo which is arguably breaking.

I don't fully understand how eth-json-rpc-errors improves error messages, or how this fixes a former break, so it might be nice to also document those two things, even just here in the PR before approve/merge.

app/scripts/controllers/provider-approval.js Outdated Show resolved Hide resolved
@rekmarks rekmarks requested a review from danfinlay September 19, 2019 02:36
Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding the extended explanation!

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.

4 participants