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: error types #1003

Merged
merged 6 commits into from
Oct 10, 2022
Merged

fix: error types #1003

merged 6 commits into from
Oct 10, 2022

Conversation

marcinbodnar
Copy link
Contributor

@marcinbodnar marcinbodnar commented Sep 30, 2022

Motivation

This is a partial restoration of changes from #910 . At this moment near-api-js is not returning proper error types for errors: AccountDoesNotExist, AccessKeyDoesNotExist, CodeDoesNotExist, InvalidNonce. Issue: #980 .

Description

  1. Restoring getErrorTypeFromErrorMessage function, with a default value change. The previous implementation was always returning UntypedError if the error message doesn't match pointed strings, which means it could possibly change the type even if it already exists, which was not ideal - this function should return the proper type if it matches, and don't change the type if not matches. If the request doesn't have a type at all, we have a proper condition to change the type if it doesn't exist in the TypedError class.
  2. Restoring usage of getErrorTypeFromErrorMessage in JsonRpcProvider.query method, but with the current message.
  3. Restoring usage of getErrorTypeFromErrorMessage in JsonRpcProvider.sendJsonRpc method.
  4. Restoring the test and also removing UntypedError case from it.

Checklist

  • Read the contributing guidelines
  • Commit messages follow the conventional commits spec
  • Performed a self-review of the PR
  • Added automated tests
  • Manually tested the change

@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2022

🦋 Changeset detected

Latest commit: 726b795

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
near-api-js Patch
@near-js/cookbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@marcinbodnar marcinbodnar linked an issue Sep 30, 2022 that may be closed by this pull request
hcho112
hcho112 previously approved these changes Oct 2, 2022
Copy link
Contributor

@hcho112 hcho112 left a comment

Choose a reason for hiding this comment

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

LGTM, wonder if we should add Changesets here?

@marcinbodnar
Copy link
Contributor Author

LGTM, wonder if we should add Changesets here?

Not sure, what do you think @esaminu ?

@esaminu
Copy link
Contributor

esaminu commented Oct 4, 2022

@marcinbodnar imo this would be a patch version bump since it's a backward compatible fix

@marcinbodnar marcinbodnar requested a review from hcho112 October 5, 2022 21:11
Copy link
Contributor

@hcho112 hcho112 left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Error types have degraded
3 participants