Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Conversation

@vcarl
Copy link
Contributor

@vcarl vcarl commented Jan 22, 2020

Per stellar/js-stellar-sdk#479, the example code here doesn't work.

.catch(function (error) {
if (error instanceof StellarSdk.NotFoundError) {
throw new Error('The destination account does not exist!');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to return the error if not an instanceof StellarSdk.NotFoundError otherwise the error will get caught here and not follow through to any subsequent catch blocks

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call

Comment on lines +58 to 64
.catch(function (error) {
if (error instanceof StellarSdk.NotFoundError) {
throw new Error('The destination account does not exist!');
} else return error
})
// If there was no error, load up-to-date information on your account.
.then(function() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It occurs to me that this demo code is broken in other ways: it says "if there was no error…" but this .then will always execute because .catch returns a resolved promise

@vcarl vcarl merged commit 44da78c into master Feb 4, 2020
@vcarl vcarl deleted the vcarl-patch-2 branch February 4, 2020 19:16
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