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

Invalid URI should cause the promise to be rejected #43

Closed
josnidhin opened this issue Apr 30, 2015 · 2 comments
Closed

Invalid URI should cause the promise to be rejected #43

josnidhin opened this issue Apr 30, 2015 · 2 comments

Comments

@josnidhin
Copy link

var rq = require('request-promise');

rq('test').then(function(){
  console.log('success');
})
.catch(function(err){
  console.log('failed')
});

Expects the code to log 'failed' on console but instead throws error

@analog-nico
Copy link
Member

Hi @josnidhin the culprit are these lines. As you see there the behavior is intentional. It is replicating Request's original behavior in case no callback is registered. The reason is that the error you reported in particular is thrown before the .then(...) method is called. So at that point in time the code cannot differentiate between:

rq('test');
rq('test').then(...).catch(...);

By nature we have a situation here that allows no perfect solution in all cases. However, it could be the case that I can find a different solution that provides a better compromise. It will take me some time to work on, though.

@analog-nico
Copy link
Member

I just released version 1.0.0 which fixes this issue.

Thanks for reporting this @josnidhin . Request-Promise embraces promises in a much more cleaner way.

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

No branches or pull requests

2 participants