-
Notifications
You must be signed in to change notification settings - Fork 20
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: new error handling #110
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- this will trigger GitGuardian
gjj
commented
Aug 20, 2020
- using INVALID_ARGUMENT and SERVER_ERROR
- installed msw (mock service worker) to mock http responses - added test case coverage for ethers SERVER_ERROR
Nebulis
reviewed
Aug 28, 2020
Nebulis
reviewed
Aug 28, 2020
Nebulis
approved these changes
Aug 28, 2020
🎉 This PR is included in version 4.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This MR attempts to fix the issues highlighted in OpenCerts/opencerts-website#517:
For reference,
In addition to the above, we also introduced error handling for
INVALID_ARGUMENT
type of errors.Decision
We decided to check Ethers error codes instead of its error messages for the two new error checks introduced in this MR.
This means that:
SERVER_ERROR
encompasses{ "bad response", "failed response", "missing response" }
bad response
,missing response
, etc.), we now group them using Ethers error codes wherever possible4xx
vs5xx
INVALID_ARGUMENT
encompasses a few funky errors that we didn't catch before like{ "incorrect data length", "hex is of odd-length" }
as explained below:61dc9186345e05cc2ae53dc72af880a3b66e2fa7983feaa6254d1518540de5
is even length, but is not 64 characters (or 32 bytes) as required of merkle roots - Ethers returns error messageincorrect data length
61dc9186345e05cc2ae53dc72af880a3b66e2fa7983feaa6254d1518540de50
is not of valid length - Ethers returns error messagehex is of odd-length
61dc9186345e05cc2ae53dc72af880a3b66e2fa7983feaa6254d1518540de50a
is OK, leaving this here for an example of a valid merkleRoot to provide context for the two errors aboveThis MR also includes the testcases for:
Finally, moved
common/smartContract/documentStoreErrors.ts
→src/verifiers/documentStoreStatus/errors.ts
since Token Registry follows the same structure.For future ref
HTTP-related errors from Ethers: https://github.com/ethers-io/ethers.js/blob/9640e864a68b4a9e84e820f0ceaf1eb56c66715f/packages/web/src.ts/index.ts
Bytes
-related errors from Ethers: https://github.com/ethers-io/ethers.js/blob/a78ca7eb8d841f8dbbdda13ef8b128a8817d10a4/packages/bytes/src.ts/index.tstl;dr there are just simply too many error messages to handle, so handling error codes (wherever possible) is a better choice in this case