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

Not all errors passed through to error message #360

Closed
bradvogel opened this issue Feb 11, 2015 · 3 comments · Fixed by #361
Closed

Not all errors passed through to error message #360

bradvogel opened this issue Feb 11, 2015 · 3 comments · Fixed by #361
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@bradvogel
Copy link

I'm seeing a lot of errors passed back to my callbacks that include a null message. Eg:

{ [Error: null] code: 500 }

However, when examining the body of the actual HTTP response, I see that the message is actually populated:

Actual response object:

 {
   "statusCode": 500,
   "body": {
     "error": {
       "errors": [
         {
           "domain": "global",
           "reason": "backendError",
           "message": "Backend Error"
         }
       ],
       "code": 500,
       "message": "Backend Error"
     }
   }
 }
@bradvogel
Copy link
Author

In examining the code, the bug appears to be here: https://github.com/google/google-api-nodejs-client/blob/master/lib/transporters.js#L93

The body is being set to null and then it's hitting the second if statement because it happens to be a 500 error.

@ryanseys Why is there a special case for 500s there? Shouldn't that be removed and just let the if statement above it handle the error? What about modify the line above from:

err.code = body.error.code;

to:

err.code = body.error.code || res.statusCode;

@ryanseys
Copy link
Contributor

Ah yeah looks like an issue with that if block. Should be an else if and probably contain a bit more logic so as to capture the case described in the two line comment about that block.

@bradvogel
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants