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

Throw TypeError when too few parameters are passed to Futures API #26

Merged
merged 1 commit into from
Apr 25, 2013

Conversation

lanthaler
Copy link
Contributor

If you have a function like

Future expand (JsonLdInput input, optional JsonLdOptions options);

and you call it without any parameters (expand()) it should throw an TypeError instead of returning a Future. You have to keep in mind that these things will most of the time be implemented in C++. You can't just omit a parameter in that case.

@dlongley
Copy link
Member

I'll accept this pull request... but it's still not clear to me that this is the desired behavior. When writing node.js-style functions that raise errors for invalid options, you pass those errors via the callback, you don't throw them. Will people using Futures also expect all errors to propagate through a rejection callback? There seems to be some degree of inconsistency here. Do you throw errors that occur during the creation of a Future or do you always create a Future, but create one that will be immediately rejected? This isn't language-specific, a C++ implementation could do the same thing ... always generate a Future but reject it if the parameters provided to the call that creates the Future are invalid.

I like the consistency w/node.js on this issue, but maybe Futures will depart from that. In any case, I'll merge this even though it causes duplication for Futures APIs that wrap node.js code (another unfortunate drawback).

dlongley added a commit that referenced this pull request Apr 25, 2013
Throw TypeError when too few parameters are passed to Futures API.
@dlongley dlongley merged commit 7d4a57e into digitalbazaar:master Apr 25, 2013
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