8000 added informative error when account is not found by rozum-dev · Pull Request #532 · near/near-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.

added informative error when account is not found #532

Conversation

rozum-dev
Copy link
Contributor

No description provided.

index.js Outdated
}
console.log(`Account ${options.accountId}`);
console.log(inspectResponse.formatResponse(state));
} catch(e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

best to move this error handling into https://github.com/near/near-cli/blob/master/utils/exit-on-error.js so that it applies to all commands

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are absolutely right that it would be better, but I can see potential problem here.
If I transfer the logic to this file and the user, for example runs the "sendMoney" command (or any other - where there is no accountId, etc.), and the server returns a weird error (for example, Currently error is "[-32000] Server error: ... "with huge stack trace.) then we get a weird wrong error case. I don't know witch cases can potentially cause "[-32000] Server error:"
How would you suggest manage those cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know the error for account being not found is:

TypedError: [-32000] Server error: account bazinga does not exist while viewing

i.e. you can check for "does not exist while viewing" substring.

index.js Outdated
console.log(`Account ${options.accountId}`);
console.log(inspectResponse.formatResponse(state));
} catch(e) {
console.log(chalk`\n{bold.red Account {bold.white ${options.accountId}} is not found in {bold.white ${config.helperAccount}} network.\n}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

need to check whether error is actually about account being not found (there can be other errors, like e.g. no Internet connection)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same as I described above.
Is there some doc on server errors response so I don't have to guess what happened.

index.js Outdated
} catch(e) {
console.log(chalk`\n{bold.red Account {bold.white ${options.accountId}} is not found in {bold.white ${config.helperAccount}} network.\n}`);

const prefix = String(options.accountId).match(/[^\.]*$/gi)[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: seems to be suffix, not prefix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just called it as it's been described in issue description, will rename np

Copy link
Collaborator
@volovyks volovyks left a comment

Choose a reason for hiding this comment

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

Please, fix these minor issues before we will approve this PR. We should manage errors in a more systematic way, but probably it should be a part of a separate PR.

@volovyks
Copy link
Collaborator

@rozum-dev Thank you for your contribution!

@volovyks volovyks merged commit d3aa943 into near:master Nov 16, 2020
crypto-guys pushed a commit to crypto-guys/near-cli that referenced this pull request Feb 18, 2021
* added informative error when the account is not found
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0