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

Set name in custom errors #403

Merged
merged 1 commit into from
Aug 8, 2019
Merged

Set name in custom errors #403

merged 1 commit into from
Aug 8, 2019

Conversation

andywer
Copy link
Contributor

@andywer andywer commented Aug 8, 2019

Because the user needs to be able to test if an error is a NotFoundError, ... or whatever.

Keep in mind that in JavaScript/TypeScript you cannot really use instanceof for that, at least not across packages. There is always a chance that there are multiple versions of the package installed somewhere in the dependency tree and testing an error thrown by stellar-sdk in version A with instanceof against a class imported from stellar-sdk version B will return false even though it is such an error, but instantiated by the other version of the same package.

Update: You cannot use instanceof, anyway, as the constructors explicitly overwrite the error's prototype.

@abuiles abuiles merged commit add8d36 into stellar:master Aug 8, 2019
@abuiles abuiles mentioned this pull request Aug 8, 2019
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.

2 participants