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

Clarify how to recognize different error types in from LPI #302

Closed
michielbdejong opened this issue Sep 20, 2017 · 3 comments · Fixed by #347
Closed

Clarify how to recognize different error types in from LPI #302

michielbdejong opened this issue Sep 20, 2017 · 3 comments · Fixed by #347

Comments

@michielbdejong
Copy link
Contributor

michielbdejong commented Sep 20, 2017

The way ilp-connector knows that a plugin throws one of https://github.com/interledger/rfcs/blob/master/0004-ledger-plugin-interface/0004-ledger-plugin-interface.md#errors is not by using instanceof because that would require shared JavaScript code between the plugin and the code that uses the plugin, or it would require the plugin to expose these error classes as constants. Instead, it looks at err.name.

I think it may be clear from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/name that an error object should have a .name field with its name, but if you look at for instance https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch and also how it's usually done in Java, C++, C#, etc. I think it doesn't hurt to add a sentence 'when catching an error, look for the .name field, which will then be the string from the left column in the table (case-sensitive)'

@emschwartz
Copy link
Member

Can this be closed now that we're switching to LPIv2?

@michielbdejong
Copy link
Contributor Author

It seems ILP v2 uses a mix of thrown errors and Promise rejections? And the PR description says "Clarify that errors should be distinguished by name", but I can't find that text, can you point to a line number?

@michielbdejong
Copy link
Contributor Author

Github closed this.

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 a pull request may close this issue.

2 participants