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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

call to getInfo() might result in surprising exception being thrown #121

Closed
azrafe7 opened this issue Mar 6, 2017 · 3 comments
Closed
Labels

Comments

@azrafe7
Copy link

azrafe7 commented Mar 6, 2017

Not sure if this should be fixed somehow, but thought I'd report it anyway (as a heads-up)... 馃槢

Using getInfo() would force you to wrap the call in a try/catch block, as the inner call to getVideoID() might throw an Error if no id is found.

Now - especially when using the promisified version - this behaviour might be surpising from a user point of view, which probably expects to grab the error in a .catch() statement.

@fent
Copy link
Owner

fent commented Mar 6, 2017

It was originally made that way because I compared it to how other native js functions handle bad parameters. But it does make sense, since this is an async function, to pass the error to the callback or the promise. Rather than having the user check two places.

@fent fent closed this as completed in d7a8672 Mar 7, 2017
MAMISHO pushed a commit to MAMISHO/node-ytdl-core that referenced this issue Feb 10, 2018
* Removing throw in inner call
* fixing tests
@cocoliliace
Copy link

I'm facing this issue on v4.3.0 when the input is not a youtube link. When I call

ytdl.getInfo("https://github.com").catch(error => console.log(error));

The catch block doesn't seem to catch anything and I get an error from the parent function instead

fent added a commit that referenced this issue Jan 2, 2021
@github-actions
Copy link

github-actions bot commented Jan 2, 2021

馃帀 This issue has been resolved in version 4.3.1 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants