-
Notifications
You must be signed in to change notification settings - Fork 93
added informative error when account is not found #532
added informative error when account is not found #532
Conversation
index.js
Outdated
} | ||
console.log(`Account ${options.accountId}`); | ||
console.log(inspectResponse.formatResponse(state)); | ||
} catch(e) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}`); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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.
@rozum-dev Thank you for your contribution! |
* added informative error when the account is not found
No description provided.