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

Fix throwing errors when using got.stream() #550

Merged
merged 1 commit into from Aug 9, 2018

Conversation

szmarczak
Copy link
Collaborator

If normalizing arguments throws and using got.stream(), it'd return a rejecting promise. This PR fixes that.

@@ -20,7 +20,11 @@ const create = defaults => {
options = mergeOptions(defaults.options, options);
return defaults.handler(normalizeArguments(url, options, defaults), next);
} catch (error) {
return Promise.reject(error);
if (options.stream) {
throw error;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could return throwing EventEmitter here. What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

No, it's a user-error and should fail immediately.

@sindresorhus sindresorhus merged commit ae5b114 into sindresorhus:master Aug 9, 2018
@szmarczak szmarczak deleted the promise-error-fix branch January 17, 2019 18:55
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.

None yet

2 participants