Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Fix for err in rejects from GoogleLogin promises being empty object #19

Merged
merged 2 commits into from
Jul 28, 2016

Conversation

Eric-Carlton
Copy link
Contributor

@Eric-Carlton Eric-Carlton commented Jul 28, 2016

I noticed that when a Promise rejects from a GoogleLogin method, the err returned in the reject is just an empty object. For example:

login.login(username, password).then(token => { //do stuff with token }, err => { console.log(err) //err prints as '{}' });

Changing the Promises to reject with the statusCode and statusMessage of the response at least gives a (reasonably) meaningful error.

I'm not sure if the same thing happens with PTCLogin methods or not. I have not tried them.

@MakuraYami
Copy link
Collaborator

Please make sure it always rejects a javascript Error object. You could do reject(Error('err text text'))

This is a common practice and helps knowing what to expect in a catch.

@cyraxx
Copy link
Owner

cyraxx commented Jul 28, 2016

Yes, wrap it in Error(..) please and I'll be happy to merge :)

@cyraxx cyraxx merged commit a5a37c7 into cyraxx:master Jul 28, 2016
@cyraxx
Copy link
Owner

cyraxx commented Jul 28, 2016

👌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants